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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Ormesome
Helper II
Helper II

DAX - max of group sums

I'm a newcomer to PowerBI and DAX, and I'm in need of help.

 

Given a dataset
Sales = (Product, Units Sold, Date)

 

I'd like to display a gauge where:
The "Value" should be the sum of all Units Sold yesterday
The "Target Value" should be the average sum of all Units Sold each Date in the time period defined by the visual level filter
The "Maximum Value" should the the maximum sum of all Units Sold each Date in the time period defined by the visual level filter.

 

I think I have 2 of 3 solved.

_first_date_of_filter = MIN('Sales'[Date])

_last_date_of_filter = MAX('Sales'[Date])

_value = SUM('Sales'[Units Sold]) / DATEDIFF([_first_date_of_filter],[_last_date_of_filter],DAY)

_target_value = CALCULATE(SUM('Sales'[Units Sold]),PREVIOUSDAY('Sales'[Date]))

 

But I can't work out how to calculate the total for each day, then to grab the maximum of those totals.

 

Any ideas?

 

 

 

1 ACCEPTED SOLUTION
Datatouille
Solution Sage
Solution Sage

Hi,

 

When you are doing Time-Intelligence calculations, it is much better to have a proper (and separate) Calendar Table.

See here: https://exceleratorbi.com.au/power-pivot-calendar-tables/ 

 

Once you have this calendar table, link it to your Sales Table with the Dates column (1 to Many relationship) and use this measure:

 

 

MaxValue = MAXX( Values(Calendar[Date] ) , Calculate(Sum(Sales[Units Sold] ) ) )

or, even better, store first this measure:

 

 

TotalUnits = Sum(Sales[Units Sold] )

 and then use this one :

 

MaxValue = MAXX( Values(Calendar[Date] ) , [TotalUnits] )

View solution in original post

1 REPLY 1
Datatouille
Solution Sage
Solution Sage

Hi,

 

When you are doing Time-Intelligence calculations, it is much better to have a proper (and separate) Calendar Table.

See here: https://exceleratorbi.com.au/power-pivot-calendar-tables/ 

 

Once you have this calendar table, link it to your Sales Table with the Dates column (1 to Many relationship) and use this measure:

 

 

MaxValue = MAXX( Values(Calendar[Date] ) , Calculate(Sum(Sales[Units Sold] ) ) )

or, even better, store first this measure:

 

 

TotalUnits = Sum(Sales[Units Sold] )

 and then use this one :

 

MaxValue = MAXX( Values(Calendar[Date] ) , [TotalUnits] )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.