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
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))

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))

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.