Forum Discussion
Assigning values based on running total and ranking within categories
Hi Anonymous
First, you need to calculate the total revenue for each category.
Total Revenue by Category =
CALCULATE(
SUM('Table'[Revenue]),
ALLEXCEPT('Table', 'Table'[Category])
)
Next, rank the products based on their revenue within each category.
Revenue Rank =
RANKX(
ALLSELECTED('Table'[Product]),
CALCULATE(SUM('Table'[Revenue])),
,
DESC,
Dense
)
Now, calculate the percentage for each product within its category.
Percentage = DIVIDE(SELECTEDVALUE('Table'[Revenue]),[Total Revenue by Category])
Finally, use the percentage to assign each product to the correct group "A", "B", or "C".
Revenue Category =
VAR CumPercent = [Percentage]
RETURN
IF(
CumPercent <= 0.20, "A",
IF(
CumPercent <= 0.50, "B",
"C"
)
)
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous2 years agoNot applicable
Hi Anonymous
Thank you, I tried it but it is not ranking corectly, see below. Apple should be marked as A and looking at total revenue category output the revenue looks the same for the whole category. Just to confirm the solution includes 4 measures ? If so how does revenue rank get pulled into the output of other measure ? Thanks