faisal
faisal

Reputation: 60

Max function for Group by is not working in Power BI

I have created one calculated column to find the max by grouping the data by country. But my group by is not working. It is always finding the max of the year (2021) for all the country without considering the country column.

My table is below and expected result is in calculated _Latest Year column :

enter image description here

My Dax formula is below:

Calculated _Latest Year = CALCULATE(MAX('MyTable'[Year]),(ALLEXCEPT('MyTable','MyTable'[Country])))

Please help me to fix this

Upvotes: 0

Views: 840

Answers (1)

Agustin Palacios
Agustin Palacios

Reputation: 1204

I tested your dax formula and it works well. However here is another option that achieve the same goal:

Latest Year = 
VAR __country = 'Table'[Country]
VAR __subTable = FILTER( 'Table', 'Table'[Country] = __country )

Return
    CALCULATE( MAX( 'Table'[Year] ), __subTable )

Upvotes: 1

Related Questions