Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hey,
Could someone please help me out with the following problem please?
Table | ||
Category | Product | Value |
Fruit | Apple | 9 |
Fruit | Banana | 8 |
Fruit | Orange | 7 |
Salad | Lettuce | 4 |
Salad | Tomato | 1 |
Desired Output | ||
NEW Product | Value | Rank |
Apple | 9 | 1 |
Banana | 8 | 2 |
Orange | 7 | 3 |
Lettuce | 4 | 1 |
Tomato | 1 | 2 |
Fruit | 24 | 1 |
Salad | 5 | 1 |
Solved! Go to Solution.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi @Anonymous ,
A little modification to the formula by @AllisonKennedy
New Table =
UNION (
SUMMARIZECOLUMNS (
'Table'[Product],
"Value", SUM ( 'Table'[Value] ),
"Rank", IF (
MAX ( 'Table'[Product] )
<> BLANK (),
RANKX (
FILTER (
ALL ( 'Table' ),
'Table'[Category]
= MAX ( 'Table'[Category] )
),
CALCULATE (
SUM ( 'Table'[Value] )
)
)
)
),
SUMMARIZECOLUMNS (
'Table'[Category],
"Value", SUM ( 'Table'[Value] ),
"Rank", IF (
MAX ( 'Table'[Product] )
<> BLANK (),
RANKX (
ALL ( 'Table'[Category] ),
CALCULATE (
SUM ( 'Table'[Value] )
)
)
)
)
)
Regards,
Harsh Nathani
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!
Hi @Anonymous,
what about the following solution:
Regards FrankAT
Hi @Anonymous ,
A little modification to the formula by @AllisonKennedy
New Table =
UNION (
SUMMARIZECOLUMNS (
'Table'[Product],
"Value", SUM ( 'Table'[Value] ),
"Rank", IF (
MAX ( 'Table'[Product] )
<> BLANK (),
RANKX (
FILTER (
ALL ( 'Table' ),
'Table'[Category]
= MAX ( 'Table'[Category] )
),
CALCULATE (
SUM ( 'Table'[Value] )
)
)
)
),
SUMMARIZECOLUMNS (
'Table'[Category],
"Value", SUM ( 'Table'[Value] ),
"Rank", IF (
MAX ( 'Table'[Product] )
<> BLANK (),
RANKX (
ALL ( 'Table'[Category] ),
CALCULATE (
SUM ( 'Table'[Value] )
)
)
)
)
)
Regards,
Harsh Nathani
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |