Forum Discussion
TopN + other values
- 7 years ago
Hi Anonymous
To calculate Others you will need to create a Column with the expression like below.Rank Top 3 Products and Others = -- add this column to your customer table VAR rnk = RANKX( 'Product', -- replace with customer table CALCULATE(SUM(Sales[Quantity])),,, -- amount column Dense ) <= 3 RETURN IF(rnk, FORMAT('Product'[Product Code], ""), "Others") -- replace Product Code with CustomerRegards,
Mariusz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
To calculate Others you will need to create a Column with the expression like below.
Rank Top 3 Products and Others =
-- add this column to your customer table
VAR rnk = RANKX(
'Product', -- replace with customer table
CALCULATE(SUM(Sales[Quantity])),,, -- amount column
Dense
) <= 3
RETURN
IF(rnk, FORMAT('Product'[Product Code], ""), "Others") -- replace Product Code with CustomerRegards,
Mariusz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous7 years agoNot applicable
Thank you for your help! The code worked perfectly, but i just have some questions about the code itself for better understanding,
In the "Rank Top 3 Products and Others" code, what is the purpose of the FORMAT code?
In the "Rank Top Three Sales" code, why do you need the IF statement after RETURN if there is no ResultIfFalse?Thank you.- Mariusz7 years agoCommunity Champion
Hi Anonymous
FORMAT(123 ,"") will return 123 as text.
IF without third argument will produce BLACK , when added to a visual it will produce only top 3.Hope this helps
Mariusz