Forum Discussion
epmck11
8 years agoFrequent Visitor
Ranking sums based on condition
Hi all,
I'm still learning DAX, and it's a bit of an adjustment for me, so any help would be appreciated. I'm trying to rank the sums of values based on criteria. Imagine I have a table like this:
| Branch | Customer | Revenue |
| ABC | McDonalds | $1,000 |
| DEF | Burger King | $1,500 |
| XYZ | Wendy's | $2,000 |
| ABC | Burger King | $500 |
| DEF | Wendy's | $750 |
| XYZ | McDonalds | $3,000 |
| ABC | McDonalds | $500 |
| DEF | Burger King | $1,000 |
| XYZ | Wendy's | $500 |
I want to be able to sum all the revenue for each branch and customer combination, and then rank them based on their total revenue for that branch. For instance, ABC - McDonalds would be ranked 1 as it has $1500 revenue, ABC - Burger King would be rank 2 as it has $500 revenue, DEF - Burger King would be ranked 1, DEF Wendy's would be ranked 2. How do I do this?
Hi, try with this measure
RankbyBranch-Customer = IF ( HASONEVALUE ( Table1[Customer] ); RANKX ( ALLSELECTED ( Table1[Customer] ); CALCULATE ( SUM ( Table1[Revenue] ) ) ) )Regards
Victor
3 Replies
- VvelardeCommunity Champion
Hi, try with this measure
RankbyBranch-Customer = IF ( HASONEVALUE ( Table1[Customer] ); RANKX ( ALLSELECTED ( Table1[Customer] ); CALCULATE ( SUM ( Table1[Revenue] ) ) ) )Regards
Victor