Forum Discussion

Baskar's avatar
Baskar
Icon for Resident Rockstar rankResident Rockstar
9 years ago

Dax - Previous Quarter

Hi,

 

Requirement :

                      1. Want to show Present Quarter and Previous Quarter in Same Visual.

Used Formula : 

                   Previous Quarter = CALCULATE   (
                                                                            COUNT('Date Master (2)'[DayOfMonth]),

                                                                             PREVIOUSQUARTER('Date Master (2)'[Date].[Date])

                                                                         )

This Measure working fine for me.

 

 

 Problem is :

                     1. When i have apply filter am not getting the Previous Quarter value.

                     2. Instead of Previous am getting Next Quarter value. Logically that is correct i can understand .

 

 

 

 

But My question is How can i get my previous Quarter value. I know have to do something on DAX. but i am cluless please help me.

 

Greg_Deckler

kcantor

v-haibl-msft

Sean

ImkeF

6 Replies

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

    Hi Baskar,

     

    From the screenshots above, I found that the quarter column added to slicer is different from that in table visual, why? In slicer, it shows 1,2,3,4 , while in table it shows Qtr1,Qtr2,ect. So, please check whether you put the correct column into slicer as a filter.

    Please add the Quarter column(Qtr1, Qtr2, Qtr3, Qtr4 ) to slicer to see whether this issue persists. Here is the result in my test.

     

    If I have something misunderstood, please provide more detailed information, like sample data, all the measures you used and relationships between tables.

     

    Thanks,
    Yuliana Gu

    • Baskar's avatar
      Baskar
      Icon for Resident Rockstar rankResident Rockstar

      How to added Quarter in Slicer, I tried to put quarter in slicer from date. but i cant able so only i created new column as quarter number.

       

       

      Can u please help how can i create slicer with Quarter fromDate . v-yulgu-msft

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

        Hi Baskar,

         

        We cannot create a slicer with Quarter from Date column directly. The same to you, I created a calculated column: 

        Quarter = 'Date Master'[Date].[Quarter], and put this column into slicer.

         

        I saw you also had this column (Quarter: Qtr1, Qtr2, Qtr3,Qtr4) in your table, why don't you drag this column into slicer? 

         

        Thanks,
        Yuliana Gu

  • kcantor's avatar
    kcantor
    Icon for Community Champion rankCommunity Champion

    Baskar

    I would recommend creating the measure for current quarter then wrapping it in dateadd by using Calculate using DAX.

    PresentQuarter = COUNT(DateMaster[DayOfMonth])

    Previous Quarter = CALCULATE([PresentQuarter], DATEADD(DateMaster[DateKey], -1, quarter))

    You would need to verify the formula for your present quarter total but the rest should be verbatium for the previous quarter assuming that your calendar table is called DateMaster and your Date Key column is called DateKey.