Forum Discussion

mandar's avatar
mandar
Frequent Visitor
3 years ago
Solved

Last 'x' days use as parameter for data refresh in PBI Dataset

Hi,

 

I have a scenario where I need to create a dynamic parameter based on which I should be able to update the data refresh.

 

For eg; if I want only the last 90 days data then I should be able to add 90. If I change my mind then I should be able to add 120 and so on. I think the way would be to some how be able to create a parameter as (today - X days) and then is what I should be able to change.

 

Below is the snippet which you give you a clear idea of what I am trying here.

 

 

  • You forgot to place  - before your parameter. That adds instead of deducting days.

4 Replies

  • Hi mandar ,

     

    You can use Date.From (DateTime.LocalNow()) to get the current date or server date if refreshed via service. Then Date.AddDays to get the date from a certain date less x number of days. Below is an example of how to dynamically filter a date colum in PQ

    = Table.SelectRows(#"Name of Previous Step", each [Date] >= Date.AddDays ( Date.From ( DateTime.LocalNow() ), -LastXDays+1 ) )

    Change LastXDays to the actual parameter name which type is Decimal Number.

     

     

    • mandar's avatar
      mandar
      Frequent Visitor

      I tried but it returns a blank

       

       

      • danextian's avatar
        danextian
        Icon for Super User rankSuper User

        You forgot to place  - before your parameter. That adds instead of deducting days.