Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello, I have a table with four columns - Store, Code, Avg Dist and Max Avg Dist(Max of Avg Dist for each store)
I am trying to find the Code which has the Max Avg Dist for each store. For example in below table - For Store A, the max avg dist is 2000 which is for code '123' and this code is populated in the right most column.
| Store | Code | Avg Dist | Max Avg Dist | Code with High Avg Dist |
| A | 123 | 2000 | 2000 | 123 |
| A | 234 | 1020 | 2000 | 123 |
| A | 456 | 1600 | 2000 | 123 |
| B | 123 | 1560 | 1900 | 789 |
| B | 456 | 1340 | 1900 | 789 |
| B | 789 | 1900 | 1900 | 789 |
| B | 91 | 1260 | 1900 | 789 |
Solved! Go to Solution.
Hi @Anonymous ,
You can create a column as below:-
Code with High Avg Dist =
VAR _high_avg =
CALCULATE (
MAX ( 'Table (2)'[Avg Dist] ),
FILTER ( 'Table (2)', 'Table (2)'[Store] = EARLIER ( 'Table (2)'[Store] ) )
)
RETURN
CALCULATE (
MAX ( 'Table (2)'[Code] ),
FILTER (
'Table (2)',
'Table (2)'[Avg Dist] = _high_avg
&& 'Table (2)'[Store] = EARLIER ( 'Table (2)'[Store] )
)
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @Anonymous ,
You can create a column as below:-
Code with High Avg Dist =
VAR _high_avg =
CALCULATE (
MAX ( 'Table (2)'[Avg Dist] ),
FILTER ( 'Table (2)', 'Table (2)'[Store] = EARLIER ( 'Table (2)'[Store] ) )
)
RETURN
CALCULATE (
MAX ( 'Table (2)'[Code] ),
FILTER (
'Table (2)',
'Table (2)'[Avg Dist] = _high_avg
&& 'Table (2)'[Store] = EARLIER ( 'Table (2)'[Store] )
)
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |