Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello all! I am having a problem on showing the max value of each group. In this example, I am trying to get one row for each state group. I tried "Top N" filter but it's not working correctly in Power BI. Below is the ideal table I want to show in Power BI
This is just a random data I created in Excel and my real file is over millions of rows so there is no way to do filter on one by one. Please let me know if anyone have a idea. Thank you so much!
Solved! Go to Solution.
Hi
if i understand your qn correctly, you want to get the max for country, state level. Made minor changes here.
Max in group = IF(CALCULATE(MAX(Table1[Score]),ALLEXCEPT(Table1,Table1[Country],Table1[State]))=MAX(Table1[Score]) ,1,0)
Please note that i have changed the column name and sample data now. So the formula also changed accordingly.
Thanks
Raj
can we sum or count column "Max in Group"?
Hi @Anonymous
Create a Measure with this DAX
Max in group = IF(CALCULATE(MAX(Table1[Score]),ALLEXCEPT(Table1,Table1[Country]))=MAX(Table1[Score])
,1,0 )
And then apply a visual filter on this measure =1. Here is the output.
Thanks
Raj
Hi @Anonymous
try ur code
Thank you so much Raj!
Your DAX measure works perfect in my example. However, my real project contains two filter and is that anywany I can do max in two filter? Imagine if there is a country column before state. For example
USA NYC Jack 10
USA NYC Ben 9
USA LA Sam 30
USA LA Tom 3
China Beijing Jon 5
India New Delhi Frank 6
Is there anyway I can get the max value for each city in USA?
I tried to use your function but it didn't show the "1" value when I have a slicer of Country.
Thank you so much for replying.
Hi
if i understand your qn correctly, you want to get the max for country, state level. Made minor changes here.
Max in group = IF(CALCULATE(MAX(Table1[Score]),ALLEXCEPT(Table1,Table1[Country],Table1[State]))=MAX(Table1[Score]) ,1,0)
Please note that i have changed the column name and sample data now. So the formula also changed accordingly.
Thanks
Raj
Hi,
I am trying to acheive the same thing and I am using this logic:
It is not an amount, but a date.
Hi,
Share some data, explain the question and show the expected result.
Hi, does somebody know why in powerpivot Excel this formula return different result that in power bi? thanks!
Thank you so much, Raj! That works perfect!!!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
77 | |
68 | |
54 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |