Forum Discussion

Shaji's avatar
Shaji
Helper I
5 years ago
Solved

Previous Quarter Calculation

Hi Great Minds,

 

So to start with I am having a Quarter Field which I derived from Month and Year field.

SO the Quarter Column formating like this:

FY20 Q4
FY20 Q3
FY20 Q1

..............so on

 

Now my requirement is to get the Sum of Sales for Current and Previous four quarters in a KPI/Card.

 

For current Sales I am getting the result using this DAX:

Total sales_current quarter = CALCULATE(SUM(Table1[sale]),FILTER(ALLSELECTED(Table1), Table1[Quarter] =MAX(Table1[Quarter])))

However, for the previous and last to previous quarters I am  not able to derive. Can you please help me out? 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Shaji 

    Seems you already have this Quarter Column, then you can create previous qtr and last to previous qtr with the following dax: 

    Previous Quarter = CALCULATE(SUM([Sales]),FILTER(ALLSELECTED('Table'),'Table'[Quarter]=MAX('Table'[Quarter])-1))
    
    Last to Pre Quarter = CALCULATE(SUM([Sales]),FILTER(ALLSELECTED('Table'),'Table'[Quarter]=MAX('Table'[Quarter])-2))

    Please see attached sample pbix if needed.


    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies