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.
Hi All,
I'm trying to create a measure that will show the amount of those not included in top 5.
I got this formula from the web
Top5 = calculate([calc measure],TOPN(6,'table',[calc measure]))
If this formula showed the correct value, then I would have used [calc measure]-top5 to show top 6 and up.
Comparing the result with a visual that shows just the top 5 and manually summing up their values, the top5 measure always has a higher value.
Proud to be a Super User!
Solved! Go to Solution.
1) Specify the column (top 5 what?) in the TOPN
Top 5 Measure = CALCULATE ( [Total Measure], TOPN ( 5, ALL ( Table[Column] ), [Total Measure] ) )
You can then subtract the above Measure from a Total Measure (one that produces overall total)
All Less Top 5 = [Total Measure] - [Top 5 Measure]
2) Alternatively you can get the same result using RANKX instead (again specify what you are ranking)
Rank Measure = RANKX ( ALL ( Table[Column] ), [Total Measure] )
Then the new Measure would look like this
All Less Top 5 = CALCULATE ( [Total Measure], FILTER ( ALL ( Table[Column] ), [Rank Measure] > 5 ) )
Hope this helps!
1) Specify the column (top 5 what?) in the TOPN
Top 5 Measure = CALCULATE ( [Total Measure], TOPN ( 5, ALL ( Table[Column] ), [Total Measure] ) )
You can then subtract the above Measure from a Total Measure (one that produces overall total)
All Less Top 5 = [Total Measure] - [Top 5 Measure]
2) Alternatively you can get the same result using RANKX instead (again specify what you are ranking)
Rank Measure = RANKX ( ALL ( Table[Column] ), [Total Measure] )
Then the new Measure would look like this
All Less Top 5 = CALCULATE ( [Total Measure], FILTER ( ALL ( Table[Column] ), [Rank Measure] > 5 ) )
Hope this helps!
Hi @Sean,
Thanks! Your second alternative works for me. I wonder though why the first one doesn't.
Proud to be a Super User!
Ya, @Sean noticed the important missing ALL( ) ! As soon as you split your measure out ... it's evaluating each column 1 at a time. So, the data only has the 1 column of data, and you are saying "Am I in the top 5, of this... set of 1?" and of course you are.
With the ALL( ) you are now saying "am I in the top 5 in the set of ALL values?" which makes entirely more sense 🙂
Just offering a variation on the excellent solution already presented.
The EXCEPT function is also useful for taking the complement of a set of values:
All Less Top 5 with EXCEPT = CALCULATE ( [Total Measure], EXCEPT ( ALL ( Table[Column] ), TOPN ( 5, ALL ( Table[Column] ), [Rank Measure] ) ) )
@OwenAugerI have in fact seen you use EXCEPT in other posts (so I should have thought of this also)
The only thing I noticed - the TOP 5 should be based on the Total Measure not the Rank Measure
All Less Top 5 with EXCEPT = CALCULATE ( [Total Measure], EXCEPT ( ALL ( Table[Column] ), TOPN ( 5, ALL ( Table[Column] ), [Total Measure] ) ) )
Great job as always!
That is so boss.
Top5 = calculate([calc measure],TOPN(6,'table',[calc measure]))
Not sure if the "6" was on purpose? I would expect a 5... for the Top 5 🙂
Other than that... the measure looks correct to me, and will evalate [calc measure], when table is filtered to just include the top 5/6, ordered by [calc measure]. (So, if [calc measure] is SUM('table'[value]), Top5 will return the total sum of values 1-5).
@Anonymous my bad, typo error.
Anyway, the first image below is of a visual with top N visual filter. The second one, is DAX TopN. As you can see, the second one has an extra column. The weird thing is that no matter how many times i change the DAX N value for the second visual, it remains the same.
Proud to be a Super User!
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 |
---|---|
108 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |