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
Al345
Frequent Visitor

Dynamic Selection N Days Prior to Date

I have a dataset that has a table of records with start and end dates and a period table that has the start and end dates of each period. I have a set of flag measures that creates a dynamic filter to show only active records that fit between a selected start and end date. Now what I need to do is have another option for the user to select N days before the start of the period and show active records based on that. I've been trying to use something like this: 

 

Measure = DATEADD(Calendar[Date], SelectedValue(NDays), DAY)

*NDays would be the value a user would select in a slicer

 

So far this hasn't worked for me but I'm sure there is a way to do this. Any ideas? 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

You can have measure like

10 Days behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],10,DAY))

 

You can use what if measure

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

N Days behind Sales =

var _max =max(Whatif[Whatifmeasure])

return

CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],_max,DAY))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @Al345 

 

If you've fixed the issue on your own please kindly share your solution. if the above posts help, please kindly mark it as a solution to help others find it more quickly.thanks!

 

 

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

Hi,

See if my solution here helps.


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

You can have measure like

10 Days behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],10,DAY))

 

You can use what if measure

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

N Days behind Sales =

var _max =max(Whatif[Whatifmeasure])

return

CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],_max,DAY))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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! Prices go up Feb. 11th.

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.