Forum Discussion

Peter_Jeyaraj_I's avatar
7 years ago

Past 4 Quarter Rolling Data Issues while applying Quarter filter

Hi, 

 

i have task to compute the past 4 quarters sum dynamically based on the quarter field in base table

then i created one mapping to accomplish ( Actual quarter , Start qtr, End qtr )

Mapping Table

Actul Quarter    StartQtr    EndQtr

20171                20161       20164

 

then applied below DAX to get running 4 qtr total.

 

Last4Qtr_Production = CALCULATE(
[Measures_Count],
FILTER(,
Table[Quarter_Field] >= CALCULATE(MIN(PPM_Goal[Start_Qtr])) &&
Table[Quarter_Field] <= CALCULATE(MIN(PPM_Goal[End_Qtr])))
)

Sum of Past 4 quarters works fine 

but i am facing other issues.. that if i apply quarter filter from mapping then other metric calculation not working

In case if i apply quarter filter from main table then this last4 quarter logic not working.. 

Help me to fix this issus. 

7 Replies

    • Peter_Jeyaraj_I's avatar
      Peter_Jeyaraj_I
      Icon for Helper II rankHelper II

      Thanks for your response

      For ex.. i have the Quarter wise count & i want to derive the last 4 quarter sum.. ie., 20151 quarter we need to consider 20141 to 20144 . here i below i shared some sample data. 

      Also, i tried to achive w/o mapping/calendar table as it's breaks other dax expression that i build in main table. 

       

      QuarterCountLast4Q Count
      20141120
      201422312
      201431635
      201445651
      2015116107
      2015227111
      2015320115
      2015460119
      2016120123
      2016231127
      2016324131
      2016464135
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Peter_Jeyaraj_I

         

        Try the following

         

        1. After loading data go to Edit Query.

         

        2. Sort the Table by th Quarter Column

         

        3. Add Index column from 1

         

        4. Create the measure 

           RunningTotal = CALCULATE(
         SUM( Table1[Count] ),
         FILTER(  ALL(Table1) ,
         SUMX( FILTER( Table1, EARLIER( Table1[Index] ) = Table1[Index] -4 ||
                               EARLIER( Table1[Index] ) = Table1[Index] -3 ||
                               EARLIER( Table1[Index] ) = Table1[Index] -2 ||
                               EARLIER( Table1[Index] ) = Table1[Index] - 1
             
                                           ) , Table1[Count] )    )      )

         

        If this works for you please accept this as solution and also give KUDOS.

         

        Cheers

         

        CheenuSing

         

        Here is the sample output.