Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi community,
Not quite sure how best to describe it, but a table should help:
UserKey | Value | Category | Return of Formula |
1 | 20 | Blue Widgets | Red Widgets |
2 | 30 | Red Widgets | Red Widgets |
3 | 40 | Green Widgets | Green Widgets |
4 | 50 | Blue Widgets | Blue Widgets |
1 | 30 | Green Widgets | Red Widgets |
5 | 40 | Green Widgets | Green Widgets |
6 | 50 | Blue Widgets | Blue Widgets |
1 | 40 | Red Widgets | Red Widgets |
As you can see, the UserKey "1" appears 3 times, with 3 different values and 3 different categories.
I'm looking for a way to write a dax formula that checks all occurences of the UserKey, then returns the category with the highest value in the new column.
In the example, I want the new column to have "Red Widgets" because it has a value of 40 in the last row.
Hope that makes sense and someone can help me out.
Thanks,
Patrick
Solved! Go to Solution.
Hello @patrick3
Give this a try.
Return of Formula = VAR _UserKey = 'Table'[UserKey] VAR _MaxValue = CALCULATE ( MAX ( 'Table'[Value] ), ALL ( 'Table' ), 'Table'[UserKey] = _UserKey ) RETURN CALCULATE ( MAX ( 'Table'[Category] ), ALL ( 'Table' ), 'Table'[Value] = _MaxValue, 'Table'[UserKey] = _UserKey )
Hello @patrick3
Give this a try.
Return of Formula = VAR _UserKey = 'Table'[UserKey] VAR _MaxValue = CALCULATE ( MAX ( 'Table'[Value] ), ALL ( 'Table' ), 'Table'[UserKey] = _UserKey ) RETURN CALCULATE ( MAX ( 'Table'[Category] ), ALL ( 'Table' ), 'Table'[Value] = _MaxValue, 'Table'[UserKey] = _UserKey )
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
63 | |
53 | |
39 | |
25 |
User | Count |
---|---|
85 | |
57 | |
45 | |
43 | |
38 |