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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Marianna
Frequent Visitor

DAX: If date not found, return next available date

Hello, I have large datasets for my pipeline and I want to compare the value of specific ID 6 months ago based on Date slicer where I filter the date, i.e. if I pick 1 Sep 23 in the date slicer, I want my dax to return the value 6 months ago based on my "Date" column in the dataset (1 Mar 23).

 

The problem is that I don't have daily data, so I need the dax measure to provide me with the value of the closest next available date, which could be 3 March 2023, or 4 Mar 2023, etc.  

 

I currently have this measure

CALCULATE([OpenPipeline],PARALLELPERIOD('Rolling Calendar'[date],-6,MONTH))

 

Any ideas on how to tweak it? Appreciate any suggestions!!

Notes on data infrastrucutre: I have a calendar table linked to all my tables via "Date" column

 

Example of dates 

Marianna_0-1693547050335.png

 

 

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @Marianna 

You can refer to the following solution.

Sample data 

vxinruzhumsft_0-1693808021150.png

Date table

vxinruzhumsft_1-1693808036498.png

e.g 

Measure = var a=CALCULATE(MAX('Table'[Column1]),DATEADD('Table 2'[Date],-6,MONTH))
var _date=CALCULATE(MIN('Table'[Date]),'Table'[Date]>(EOMONTH(SELECTEDVALUE('Table 2'[Date]),-7)+DAY(SELECTEDVALUE('Table 2'[Date]))),CROSSFILTER('Table 2'[Date],'Table'[Date],None)) 
return IF(a=BLANK(),CALCULATE(MINX(FILTER('Table',[Date]=_date),[Column1]),CROSSFILTER('Table'[Date],'Table 2'[Date],None)),a)

Best Regards!

Yolo Zhu

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

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @Marianna 

You can refer to the following solution.

Sample data 

vxinruzhumsft_0-1693808021150.png

Date table

vxinruzhumsft_1-1693808036498.png

e.g 

Measure = var a=CALCULATE(MAX('Table'[Column1]),DATEADD('Table 2'[Date],-6,MONTH))
var _date=CALCULATE(MIN('Table'[Date]),'Table'[Date]>(EOMONTH(SELECTEDVALUE('Table 2'[Date]),-7)+DAY(SELECTEDVALUE('Table 2'[Date]))),CROSSFILTER('Table 2'[Date],'Table'[Date],None)) 
return IF(a=BLANK(),CALCULATE(MINX(FILTER('Table',[Date]=_date),[Column1]),CROSSFILTER('Table'[Date],'Table 2'[Date],None)),a)

Best Regards!

Yolo Zhu

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

 

JoeBarry
Solution Sage
Solution Sage

Hi @Marianna 

 

Adapt your your measure to 

 

CALCULATE([OpenPipeline],DATEADD('Rolling Calendar'[date],-6,MONTH))

 

PARALLELPERIOD will get the value for the whole month whereas DATEADD is date specific. Add the Date from the Date table in the slicer as this will show all dates. If you scroll to March 3rd then you will see data from Sept 3rd

 

Thanks

Joe

If this post helps, then please Accept it as the solution

 

 

Hi @JoeBarry thank you for the suggestion!!! But what if I do not have data on March 3rd? 

If I select September 3rd, and I do not have data for March 3rd date (backwards 6 months), I need to see the next date that I have, which might be March 5

Helpful resources

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

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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