Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
418 views
in Technique[技术] by (71.8m points)

powerbi - 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 coluumn: 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

question from:https://stackoverflow.com/questions/65935878/max-function-for-group-by-is-not-working-in-power-bi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 )

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...