Forum Discussion

PeterChen's avatar
PeterChen
Icon for Helper I rankHelper I
7 years ago
Solved

Last four quarters rate

I have a data like this: I just show a simple table, but column Date is from 2015 to 2019/6/30, column Group has 4 groups (A-D), and column value is numeric that the numbers are different rath...
  • Anonymous's avatar
    Anonymous
    7 years ago

    If I understand you correctly you want to put all the Dates in to a YYYYQ format:

    (YQ = Concatenate(DateField.[Year], Concatenate("Q", DateField[QuarterNo])) As a Column

     

    Then you want a Total of the last 4 Quarters 

    (L4QrAll = Calculate(Sum(ValueColumn), Filter(All(TableName), YQ  = // This is where I cannot make it dynamic however it will work but you will have to change it when we enter a new quater// "2019Q2" || YQ = "2019Q1" || YQ= "2018Q4" || YQ= "2018Q3")) As a Measure

     

    Then a Measure for the Group Values

    (L4QrEach = Calculate(Sum(ValueColumn), Filter(TableName, YQ  = "2019Q2" || YQ = "2019Q1" || YQ= "2018Q4" || YQ= "2018Q3")) As a Measure

     

    Finally the Rate

    Rate = Divide(L4QrEach, L4QrAll) As a Measure

     

    Note:  This will not create a table like the one you had. This is due to level of detail. However, if you create a table like yours without the YQ field it will aggregate to the group level.

     

     

    I hope this helps

     

    This is the data I created to test it.