Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
This is my model
The Data:
How can I get the lowest rank by year and type of school?
This is the desired output.
Thanks
Hi @SammyPub,
You can write a formula with 'countrows' and filter based on the current year and type group.
Using the SELECTEDVALUE function in DAX - SQLBI
LRank =
VAR currYear =
MAX ( Table[Year] )
VAR summary =
SUMMARIZE (
ALLSELECTED ( Table ),
[Year],
[School],
"Total", SUM ( Table[value] )
)
RETURN
COUNTROWS (
FILTER (
summary,
[Year] = currYear
&& [Total] > SUM ( Table[value] )
)
) + 1
Regards,
Xiaoxin Sheng
Hi Xiaoxin Sheng. Thanks for your help.
If it helps. here's the pbix: file
I made a little change since I am looking for the ranking of the grades average and not the sum of the grades.
LRank =
VAR currYear =
MAX ( Results[Year] )
VAR summary =
SUMMARIZE (
ALLSELECTED( Results ),
[Year],
[IdSchool],
"Total", AVERAGE ( Results[Grade] )
)
RETURN
COUNTROWS (
FILTER (
summary,
[Year] = currYear
&& [Total] > AVERAGE ( Results[Grade] )
)
)
I understand the logic, but the results are not what I was expecting:
I'm looking for the rankings for the best grades by year
What's wrong?
Thanks
Hi @SammyPub,
I think this should more relate to your visual fields.
My formula is based on school and year but you change them to use school type and it will affect the condition to compare with AVERAGE ( Results[Grade] ) results.
In addition, when you use school type(mapping to multiple schools) as category, power bi will aggregate with these school values. How did you handle this level of aggerate? (Dax expression can't directly calculate with multiple aggregates, you need to add summarize function and iterator functions for different level calculates)
Measure Totals, The Final Word
Regards,
Xiaoxin Sheng
User | Count |
---|---|
84 | |
76 | |
74 | |
49 | |
39 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |