Forum Discussion

Al345's avatar
Al345
Frequent Visitor
6 years ago
Solved

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? 

3 Replies

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

  • v-diye-msft's avatar
    v-diye-msft
    Icon for Community Support rankCommunity 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!