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
MontyZero
New Member

Total sum of max date values

Hi

 

I am trying to get the maximum value for each company in a filtered table. This is the dax I have been using 

 

 

Most Recent Total Value:=
VAR maxdatekey=
MAXX(FILTER('Reporting Table',
'Reporting Table'[ReportingDateKey] <= [ReportingDateParamEnd]
&& 'Reporting Table'[ReportingDateKey] >= [ReportingDateParamStart]
&& 'Reporting Table'[Scenario] = "Total Value"
),
'Reporting Table'[ReportingDateKey])
RETURN
(
CALCULATE([NumericValue], 
FILTER('Reporting Table',
'Reporting Table'[Scenario] = "Total Value"
&& 'Reporting Table'[ReportingDateKey] = maxdatekey
)
)
)

I filter the table based on dates selected, and a scenario to generate the maximum date value. I then use the same filters plus the max date to return the amount required.

 

 

At a granular level the measure works correctly with the following output

 

CompanyIDReportingDateKeyMost Recent Total Value
120180101100
220180101100
320180101200
420140101300
520180101100
  800

 

The issue arises when I remove the granular slicers. The max date is calculated to be 20180101 and the filter causes CompanyID 4 to be excluded. The total returns as 500 rather than 800.

 

Most Recent Total Value

500

 

Is there a way to force the calculation to calculate the total correctly?

 

Thanks in advance

Michael

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

See if this Quick Measure, Measure Totals, The Final Word gets you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

See if this Quick Measure, Measure Totals, The Final Word gets you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Great! Thanks Greg.

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.

Top Solution Authors