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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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])  ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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