Forum Discussion
Anonymous
7 years agoNot applicable
TopN + other values
Hello, I'm trying to create a topN + other values table. As a simple example, i have a table that looks like this: customer amount A 1 B 2 C 3 D 4 E 5 and i woul...
- 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.
Anonymous
7 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.
Mariusz
7 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