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

Custom End Date

Select a end date from a filter and use it to calculate last 90 days and last 120 days. The Custom End date should not apply to any visual on the report. it should only be used for calculation (last 90 and 120 days)

I am currently doing this 

 VAR OneYearAgo =  CALCULATE(
    COUNTROWS('DateTable'),
 FILTER('DateTable',
 'DateTable'[Month Year]>=MaxDate-90 && 'DateTable'[Month Year]<=MaxDate)
but it is only returning the selected end date and not the range, please help!
1 ACCEPTED SOLUTION
Sandvik19
New Member

Thanks a lot for your responses! I used a disconnected date table to get the end date now this code works perfectly!

VAR MaxDate =  SELECTEDVALUE('DisconnectedTable'[Month Year])



 VAR OneYearAgo =  CALCULATE(
    COUNTROWS('DateTable'),
 FILTER('DateTable',
 'DateTable'[Month Year]<=MaxDate && 'DateTable'[Month Year]>=MaxDate-90)

View solution in original post

4 REPLIES 4
Sandvik19
New Member

Thanks a lot for your responses! I used a disconnected date table to get the end date now this code works perfectly!

VAR MaxDate =  SELECTEDVALUE('DisconnectedTable'[Month Year])



 VAR OneYearAgo =  CALCULATE(
    COUNTROWS('DateTable'),
 FILTER('DateTable',
 'DateTable'[Month Year]<=MaxDate && 'DateTable'[Month Year]>=MaxDate-90)
Ashish_Mathur
Super User
Super User

Hi,

This pattern should work.  I have assumed that you have already written a measure named MaxDate.

VAR OneYearAgo =  CALCULATE(COUNTROWS('DateTable'),DATESBETWEEN(Calendar[date],[MaxDate]-90,[MaxDate]))

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Is that 'DateTable' disconnected from your data model?

No the datetable is connected

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.