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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
scotjn1
Helper I
Helper I

calculate a measure only for the last/final date in the current context

Hello everyone,

I have a measure (Avg MIS) that calculates an average value over all months in a given context.  For example, in the visual below, the 2016 value of 21 is for all of 2016, the 19 value for Q1 is for the three months shown, etc.  What I would like to do is get a separate measure (Avg Ending MIS) that shows the average value for the final month in the given context, as shown by the arrows.  No matter what date ranges are selected or how they are grouped, the calculated value displayed would always be based on the last date available in the given context.

 

The _maxdt measure is just a placeholder to ensure that the last date was getting picked up correctly in context.

 

My measures:

Avg MIS = AVERAGE(estimates[calc_MIS])
_maxdt = MAX(dates[Bill Date])

 

Essentially, this is what i'm hoping to accomplish, but it obviously gives an error:

 

Avg Ending MIS = CALCULATE([Avg MIS],dates[Bill Date]=[_maxdt])

 

I expect the solution some combination of FILTERing and/or variables.  I've tried all manner of things for Avg Ending MIS, but this is well beyond my limited skillset.

 

Thanks for any advice you can offer!

 


image389.jpg

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@scotjn1,

Please change your DAX to the following:

Avg Ending MIS = var datepara= [_maxdt] return CALCULATE([Avg MIS],FILTER(dates,dates[Bill Date]=datepara))

1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@scotjn1,

Please change your DAX to the following:

Avg Ending MIS = var datepara= [_maxdt] return CALCULATE([Avg MIS],FILTER(dates,dates[Bill Date]=datepara))

1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Awesome, thanks so much!!!  I knew it had to be something like that, but nothing I did was just the right combination!

Helpful resources

Announcements
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.