Forum Discussion

SunilMauryaPBI's avatar
SunilMauryaPBI
Frequent Visitor
8 years ago

How to implement AGO in POWER BI

Hi, 

I need help to understand how i can implement AGO type measures in POWER BI.

I need to display conversion price for yyyy/mm selected by user along with its values 1 month back, 3 month back, 6 month back and 12 month back. For example:-

If 2018/03 is slected, then row should look like this and I placed the model in below.

 

 

2 Replies

  • Any help will be appreciated? I want 4 measures to be in place like

    Stock price 1 month ago

    Stock price 3 month ago

    Stock price 6 month ago

    Stock price 12 month ago

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi SunilMauryaPBI,

     

    1. Remove the relationship between 'Date Dimention' and 'Stock Price Fact'.
    2. Create calculated columns, for example, calculate the date one month ago. 1 month ago =
      DATEADD ( 'Date Dimention'[Calendar_Date], -1, MONTH ). Set its format to "MMMM yyyy" under Format list in top ribbon.
    3. Add 'Date Dimention'[CAL_MONTH] to slicer. Add 'Stock Price Fact'[RWPORTING_PERIOD_ID] to table visual.
    4. Create measures:
      Selected value of 1 month ago =SELECTEDVALUE ( 'Date Dimention'[1 month ago] )
      
      % Mov 1 Month Ago =
       (
          CALCULATE (
              [Sum value],
              FILTER (
                  'Stock Price Fact',
                  YEAR ( 'Stock Price Fact'[EFFDATE] ) = YEAR ( [Selected value of 1 month ago] )
                      && MONTH ( 'Stock Price Fact'[EFFDATE] )
                          = MONTH ( [Selected value of 1 month ago] )
              )
          )
              - [Sum value]
      )
          / [Sum value]

    Regards,

    Yuliana Gu