Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
saglamtimur
Resolver II
Resolver II

DAX measure to calculate MAX for a given group

Hi,

 

I have data like

 

max.PNG

 

I need a measure to calculate MaxItemPrice. I have lots of filters which are not show, and grouping may be changed (eg:CustomerName->ItemName->StateName or StateName->Customername->ItemName). How can I achieve this? Thanks.

6 REPLIES 6
v-chuncz-msft
Community Support
Community Support

@saglamtimur,

 

It seems that you just need to use the Matrix visual.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have already, but still problem exists.

@saglamtimur,

 

The simple MAX Function seems to be working. Show us the expected result more clearly.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

What I would like to achieve

 

4.PNG

DAX0110
Resolver V
Resolver V

If I understand you correctly, you want to compute the maximum price for an item across all customers in all states, regardless of other filters that are in place?

 

You can try this measure: (assuming the name of the table is ItemPrices)

 

=CALCULATE(

             IF( HASONEVALUE(ItemPrices[ItemName])

                 , MAX(ItemPrices[ItemPrice])

                 , BLANK()

                 )

           , ALLEXCEPT( ItemPrices, ItemPrices[ItemName] )

           )

 

This formula will return blank for subtotal and grand total cells, unless that total pertains to exactly one item.

 

Thanks for your quick reply.

All filters should be applied, like Year, Month, Country etc...

This works in Excel, users can change the order of grouping as I mentioned.

Subtotals and grand total are not important for me. I left them blank just to separate groups.

 

I believe, I cannot apply filters properly. Simple MAX(ItemPrices[ItemPrice]) works for each given ItemName, but the shown value is max of all without applying filters.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.