Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Dynamic parameter for calendar with data source from SAP BW

Dear all,

May I get your help on below issue.

I create a report with data source from SAP BW that I have to select parameter of calendar (month) when getting data to the report. It is the fixed selection and I have to adjust the parameter after a period.
In case I want to get dynamic parameter (Ex: last month + current month) then I do not have to update the parameter anymore.

Below is the code of parameter:

{Cube.ApplyParameter, "[YCALMONT]", {{"[YORDMONTH].[202010]", "[YORDMONTH].[202011]", "[YORDMONTH].[202012]"}}},

Appreciate your advice.

Thank you!

 

4 Replies

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, Anonymous 

     

    You may create two queries with the following codes to get lastmonth and current month and then refer to these two queries in other query. The pbix file is attached in the end.

    Query1:

     

    let
        Source = let 
    d = DateTime.Date( DateTime.LocalNow())
    in
    Date.Year(d)*100+Date.Month(d)
    in
        Source

     

     

     

    Query2:

     

    let
        Source = let 
    d = DateTime.Date( DateTime.LocalNow()),
    dlastmonth = Date.AddMonths(d,-1)
    in
    Date.Year(dlastmonth)*100+Date.Month(dlastmonth)
    in
        Source

     

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • zadullabja's avatar
      zadullabja
      Regular Visitor

      Hi Allan, Thank you for your post. Really helped me. But how do i apply this to my query? 

      {Cube.ApplyParameter, "[YCMPERB]", {{"[0CALMONTH].[202301]"}}},

      • Ajay346's avatar
        Ajay346
        Regular Visitor

        Did you find any solution to it