Forum Discussion
Top N filter + other
- 4 years ago
Hi,
Please check the below picture and the attached pbix file.
Only show top3 and Oracle: =
VAR top3table =
TOPN ( 3, ALL ( Data[Companies] ), CALCULATE ( SUM ( Data[Revenue] ) ), DESC )
RETURN
IF (
HASONEVALUE ( Data[Companies] ),
SWITCH (
TRUE (),
SELECTEDVALUE ( Data[Companies] ) = "Oracle", SUM ( Data[Revenue] ),
CALCULATE ( SUM ( Data[Revenue] ), KEEPFILTERS ( top3table ) )
)
) - 4 years ago
Hi,
Thank you for your message.
When you see the previous measure, there is a IF condition that says "if there is one company in the row, then show the result, otherwise blank".
if I do not write this, then it shows the wrong total, and I did not know whether readers want to see the total or not. I thought showing blank is better than showing a wrong total.
If you want to show the total, then please try the below.
Only show top3 and Oracle: =VAR top3table =TOPN ( 3, ALL ( Data[Companies] ), CALCULATE ( SUM ( Data[Revenue] ) ), DESC )RETURNSUMX (VALUES ( Data[Companies] ),CALCULATE (SWITCH (TRUE (),SELECTEDVALUE ( Data[Companies] ) = "Oracle", SUM ( Data[Revenue] ),CALCULATE ( SUM ( Data[Revenue] ), KEEPFILTERS ( top3table ) ))))
Thanks for the solution. May I know why it doesn't aggregate to grand total ?
Hi,
Thank you for your message.
When you see the previous measure, there is a IF condition that says "if there is one company in the row, then show the result, otherwise blank".
if I do not write this, then it shows the wrong total, and I did not know whether readers want to see the total or not. I thought showing blank is better than showing a wrong total.
If you want to show the total, then please try the below.
- KN84 years agoFrequent Visitor
Awesome thanks again for the explination and the solution.