Forum Discussion

Qualube's avatar
Qualube
Helper II
7 years ago
Solved

Running Comparion to previous year

Hi

 

I need to establish the comparative volumes from the previous year against the current year. I think I am part way there but can't finalise the measure to achieve this.

 

 

I know I need to filter the sales table to identfy the last delivery date

 

FILTER(SALESLINE,SALESLINE[DELIVERY DATE] >= MAX(SALESLINE[DELIVERY DATE]))

 

This then gives me the volumes up to the last delivery date in the current year but I can't seem to pin down the dax funtion to do the comparison to the exact same time last year  whether it's PARRELLPERIOD or DATESBETWEEN

  • Qualube,

     

    Glad to hear that. You may help accept the solution above. Your contribution is highly appreciated.

8 Replies

  • Hi,

     

    Use the SAMEPERIODLASTYEAR() function.  To get more specific help, share your data and show the expected result.

    • Qualube's avatar
      Qualube
      Helper II

      Hi Ashish

       

      I am pretty new to DAX but I am really enjoying the learning process. I have broken this problem down into smaller less complex steps and I have the first measure written which basically SUMX the volume of product sold from the 1st April until the last delivery date. This gives me a running total of volumes sold but what I would like to do is take this running total and see the exact same timeframe last year as a comparison.

      I have tried to use the measure below in a SAMEPERIODLASTYEAR function but cannot get the syntax right.

       

      RT VOLUME = CALCULATE(SUMX(SALESLINE,SALESLINE[NEW VOLUME]), DATESBETWEEN('DATE'[Date], 
          DATE(2018,4,1), 
          MAX(SALESLINE[DELIVERY DATE]) 
        ))

       

      What I would like to do is take

       

      • Qualube's avatar
        Qualube
        Helper II

        Just a quick update, tried:

         

        PY RUNNING TOTAL =
        CALCULATE (
            [RT VOLUME],
            SAMEPERIODLASTYEAR ('DATE'[Date])
        )

         

        But it gives me exactly the same figures as [RT VOLUME] so can't seem to make sense of that!!!

         

        Thanks