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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
alanbbarton
New Member

Max Value based on two categories

Need help trying to get a number based on the year and the week.  I cannot just create a new measure in the original query but need to create a new measure in the visulization itself (data is detail level and the field I am reporting on is repeated many times - thus he max will get what I need).

 

I have tried the following but cannot figure out how to get the second criteria.

 

Max of Westpack max per Year =
MAXX(
    KEEPFILTERS(VALUES('ExternalNumbers'[Year])),
    CALCULATE(COUNTA('ExternalNumbers'[Westpack]))
)
I need  to also filter by 'ExternalNumbers'[Week_Number].
 
FOR EXAMPLE
Employee CodeHoursYearWeekWestPac
1232482022118
35465720221

18

6548762022118
1232452022220

 

What I need it to tell me that for Year 2022 Week 1 its 18 and for Year 2022 Week 2 its 20.  

 

Hope that helps more!

2 REPLIES 2
alanbbarton
New Member

Almost there but apparently the fields (all three) are text and it must be a number.  Now I tried to change it in the table using Change Type but I am getting other issues.  Is it possible to change the fields to number in DAX?  I tried the following and it failed:

 

Sumx(summarize(Table, VALUE(Table[Year]) , VALUE(Table[Week]), "_1", Max(VALUE(Table[WestPac]))),[_1])

 

 

 

 

amitchandak
Super User
Super User

@alanbbarton ,

 

Sumx(summarize(Table, Table[Year] , Table[Week], "_1", Max(Table[WestPac])),[_1])

 

 

or

 

calculate(Sumx(summarize(Table, Table[Year] , Table[Week], "_1", Max(Table[WestPac])),[_1]), Filter(allselected(Table), Table[Year] = Max(Table[Year])  && Table[Week] = Max(Table[Week])  ) )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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