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

Measure to capture MAX value based on filter selections

Hello,
 
I am a somewhat newbie to power BI and DAX, and trying to muddle my way through a particular issue.
 
I have a report set-up that displays a chart with Forecasted Sales $ over time.  I also have a filter for users to choose the specfic date(s) for which they want to display the data ("DateStamp").
 
I am trying to create a measure that will display the Total Sales $ value, of the Maximum selected DateStamp (latest date).  However, the result I am getting is a total of ALL Cumulative Sales $, for ALL date stamps selected. 
 
Do I have an error in my DAX statement? 
 
EndingCUM_ForMaxDtStamp = CALCULATE(SUM(FCST[FCST_Sales$]),
FILTER(FCST,FCST[DateStamp]=CALCULATE(MAX(FCST[DateStamp]),ALLSELECTED((FCST[DateStamp]))))
 
 
1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @jrobb 

 

Try this measure:

EndingCUM_ForMaxDtStamp =
VAR _Max_Date =
    MAX ( FCST[DateStamp] )
RETURN
    CALCULATE (
        SUM ( FCST[FCST_Sales$] ),
        KEEPFILTERS ( FCST[DateStamp] = _Max_Date )
    )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @jrobb 

 

Try this measure:

EndingCUM_ForMaxDtStamp =
VAR _Max_Date =
    MAX ( FCST[DateStamp] )
RETURN
    CALCULATE (
        SUM ( FCST[FCST_Sales$] ),
        KEEPFILTERS ( FCST[DateStamp] = _Max_Date )
    )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

This worked perfectly.  Thanks @VahidDM !

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