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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JulietZhu
Helper IV
Helper IV

DAX for last N month end day with single month selection

I need last 13 month trending data with one month slicer (not date range). Also for each month, I only need capture the last day's data and not sum the whole month.  For example, if Aug 2018 is chosen, I need show data for 08/31/2018, 07/31/2018, 06/30/2018, 05/31/2018 etc. 

 

The DAX I am using is 

 

TaskOutstanding_RCM(last 13 months) =
VAR MaxFactDate =
CALCULATE ( MAX ( Task[CreatedDate]), ALL ( 'Date') )
VAR FDate =
ENDOFMONTH ( 'Date'[Date] )
VAR Edate =
EDATE ( FDate, -13 )
VAR Edate1=IF(DAY(FDate)=30,Edate+1,IF(DAY(FDate)=28,Edate+3,IF(DAY(FDate)=29,Edate+2,Edate)))
RETURN IF ( MaxFactDate <= MAX ( 'Date'[Date] ) && MaxFactDate > Edate1,
CALCULATE ( Task[TaskOutstanding] , ALL('Date'[EOM])))

 

But the result is not correct. Please help the above DAX. Thanks
The dummy data link:  https://1drv.ms/u/s!AlYpYKwSuOKxhFq5jYCx180jIA1A

 

14.PNG

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi, @JulietZhu

Your measure with data model is a little bit complicated, This relates to the row context and filter context, you filter Date (bins), but drag createddate (bins) into table visual.

For example:

if Aug 2018 is chosen, TaskCompleted should be 61587 in Aug 2018, but it is divided into the different createddate (bins).

So if you need to use Date (bins) in visual and measure instead of  createddate (bins).

hope it can help you.

I will have a try on it too.

 

Best Regards,

Lin

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.