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
tabbey
Frequent Visitor

DAX Calculate the MAX of a MAX

Hi there,

 

I am new to DAX and has spent days trying to figure this out. I need to find a MAX of MAX. 

 

The sample here shows the MAX sales by weekday. It is derived by using the MAX function, MAX(Sales). I need a second MAX column that shows the MAX of all weekday. Simply put, MAX of the first MAX(Sales), MAX(MAX(Sales)).

 

The Weekday is from DimDate table, which is referred by the FactSales Table.

 

I've tried all options i found online but with no luck. Any suggestion?

 

WeekdayMAX(Sales)MAX(Max(sales))
Monday10005000
Tuesday2005000
Wednesday25005000
Thursday30005000
Friday15005000
Saturday50005000
Sunday25005000

 

Thanks,

TH

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

HI @tabbey

 

Please try this pattern in your calculated measure

 

Measure = 
VAR X = SUMMARIZE(ALL('DimDate'),'DimDate'[Weekday],"M",MAX('FactSales'[Sales]))
RETURN MAXX(x,[M])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Employee
Employee

HI @tabbey

 

Please try this pattern in your calculated measure

 

Measure = 
VAR X = SUMMARIZE(ALL('DimDate'),'DimDate'[Weekday],"M",MAX('FactSales'[Sales]))
RETURN MAXX(x,[M])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Finding Max of Max in Power BI - BY RAKSHA GANGWAL
Problem Statement: Hi, As I can understand your situation
We have a table as below:
MaterialNo.   MDno.  MD_Item.
ABC10            7                 10
ABC10            8                  3
ABC10            9                  4
PQR10            7                 10
PQR10            8                  3
XYZ10             9                  4

Expected Solution: In this Case, It should first take Max of MDno. based on Material No. and then take Max of MD_item. based on previous max MDno. Accordingly, the result being as follows:
MaterialNo.   MDno.  MD_Item
ABC10            9                  4
PQR10            8                  3
XYZ10             9                  4

Solution: We can create a summarize table using the dax code as shared below:

SELECTCOLUMNS (
    SUMMARIZE (
        FILTER (
            MaterialTransaction,
            MaterialTransaction[MDno] = CALCULATE (
                MAX ( MaterialTransaction[MDno] ),
                ALLEXCEPT ( MaterialTransactionMaterialTransaction[MaterialNo] )
            )
        ),
        MaterialTransaction[MaterialNo],
        MaterialTransaction[MDno],
        "Max MDItemNo"MAX ( MaterialTransaction[MDItem] )
    ),
    "MaterialNo"MaterialTransaction[MaterialNo],
    "MDNo"[MDno],
    "MD_Item"[Max MDItemNo]
)


Note: Material Transaction is the name of Base Table here, you can add your table name or necessary column name and tweak the code. Give it a like if this solves your issues. Thanks 🙂

 

OMG! You're my hero!! It worked!! Thank you Phil_Seamark.

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.