Forum Discussion

jayanthan's avatar
jayanthan
Icon for Helper III rankHelper III
7 years ago

Dynamic Previous Year Sales

Hi All

 

how can i create a dynamic previous year sales

 

E.g if i select 2015, i need to retrieve 2014 sales, if i select 2014, i need to retrieve 2013 sales. Also note my financial year ends on 31st March. 

 

I have tried with below DAX Function , but it didnt not work

 

1. 

PreviousYearbySelection

 

 VAR CurrentYear=

CALCULATE(FIRSTNONBLANK('Z_Power BI Date Template'[Year], ISFILTERED('Z_Power BI Date Template'[FinancialYear]) ))
Return
CurrentYear-1

 

2.Sales_Previous_Year_Selection =

CALCULATE

(sum

('Sales Comparison'[BaseSubTotal]),

filter ('Z_Power BI  Date Template','Z_Power BI  Date Template'[Year]=[PreviousYearbySelection]

)

)

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Have you tried SAMEPERIODLASTYEAR ?

     

    E.g.

    Calculate(

    (sum

    ('Sales Comparison'[BaseSubTotal]); SAMEPERIODLASTYEAR("yourdatetable";[date])

    )

    • jayanthan's avatar
      jayanthan
      Icon for Helper III rankHelper III

      hi Larstc 

       

      it will not work when financial year ends on 31st March

       

       

      Regards

      Jayanthan