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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Lygral63
Helper I
Helper I

DAX measure (Max/Min)

DAX measures for Max and Min

 

I am looking for the best way to calculate a measure that will compare sales from multiple year in a given Calendar Week and returning the max value. The measure should return the max by Calendar Week based on total sales (eg. sum of countries). I would need the same kind of measure for Min. Any suggestions?

 

Table: Data     
      
CountryProductYearCalendar Week Sales 
AC20151100 
AC20152200 
AC20161150 
AC20162125 
BC20151200 
BC20152250 
BC20161100 
BC20162150 
      
      
Calendar WeekYearTotal Sales   
12015300   
12016250   
22015450   
22016275   
      
Output     
      
Measure should return:    
      
Calendar Week     
1300    
2450    
      

 

1 ACCEPTED SOLUTION

Yes, it's works. Thanks a lot. Much more simple than I expected. Thanks.

View solution in original post

8 REPLIES 8
FreemanZ
Super User
Super User

hi @Lygral63 ,

 

not sure if i fully get you, please try to plot a table visual with two measure like:

WeeklyMax = 
MAXX(
    VALUES(data[Year]),
    CALCULATE(SUM(data[Sales]))
)
WeeklyMin = 
MINX(
    VALUES(data[Year]),
    CALCULATE(SUM(data[Sales]))
)

 

it worked like:

FreemanZ_0-1698672358742.png

 

I appreciate the effort, but I can't the the result I am expecting. The problem is that I have multiple years and need to max value from Calendar Week 1 (across all years), then the max from Calendar Week 2 (across all years) etc. So in total the measure should return the max value for every Calendar Week comparing data from all years.  I hope that makes it a bit more clear.

 

Hi, @Lygral63 

 

try below 

result =
calculate(max('table (2)'[total sales]),removefilters(''table (2)'[year]))

 

Dangar332_0-1698747084394.png

 

if not work then provide week1 and week 2 data

CountryProductYearCalendar WeekSales
AD20151100
AD20152200
AD20153150
AD20161300
AD20162200
AD20163100
BD20151200
BD20152150
BD20153450
BD20161500
BD20162300
BD20163250
CD20151125
CD20152100
CD20153150
CD20161175
CD20162200
CD20163150
     
Calendar Week20152016Measure should return 
1425975975 
2475700700 
3750500750 

hi @Lygral63 ,

 

the proposed measure still works, or?  

FreemanZ_0-1698760278317.png

 

Yes, it's works. Thanks a lot. Much more simple than I expected. Thanks.

Dangar332
Super User
Super User

Hi, @Lygral63 

 

try below code 

 

min sales by week = MIN('calender week'[Total Sales])

 

max sales by week = max('calender week'[Total Sales])

 

Dangar332_0-1698416566110.png

 

Thanks, but I don't think that works. I need a measure that looks at total sales by Year and by Calendar Week and then returns the max or min value. It could be that in Calendar Week 1 has the max value based on sales in 2016, but Calendar 2 has the max value based on sales in 2015. Hope it makes sense.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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