Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Combining dynamic date filter in Power Query (import) with date conversion

Hi, I have a Query (SAP HANA) connected to my Power BI as an import. When importing the data, I choose my date span (either from a certain date, between certain dates). I would like to create a dyna...
  • Jimmy801's avatar
    5 years ago

    Hello Anonymous 

     

    Check out this dynamic solution. Use this output as input in your Cube-parameter

    let
        Yesterday = Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1),
        Year = Text.From(Date.Year(Yesterday)),
        Month = "0" & Text.From(Date.Month(Yesterday)),
        Day = "0" & Text.From(Date.Day(Yesterday)),
        Final = Year & Text.End(Month,2) & Text.End(Day,2)
    in
        Final

     

    Copy paste this code to the advanced editor in a new blank query to see how the solution works.

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy

  • Jimmy801's avatar
    Jimmy801
    5 years ago

    Hello Anonymous 

     

    where is this error caused? Did you input my code into the blank query? And it's the name "Query1"?

     

    If you can answer both questions with yes, then this error is caused by something else. Maybe somewhere else in your code you are using a variable without definition.

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy