Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Unable to plot Current Year vs Previous Year

Hi Team,

 

Need your assistance, I am unable to plot current year vs previous year in PowerBI.

My Sample data looks like this


YearMonthSalesQty

202303

705
202302654
202301852
202212705
202211674
202210855

202209

705
202208654
202207855
202206759
202205654
202204835
202203203
202202306
202201564



My Requirement:
Filters: Year ,Month
Line and Clustered Column Chart:
x-Axis =
Month
y-Axis =
CY,PY Values (CY=Current Year, PY=Previous Year)

Secodary y-Axis = Growth% (CY-PY/PY)

When i select Year 2023, the data has to show SalesValues of 
          CY =202301 to 202303 
           PY = 202201 to 202203

When i select Year 2022, the data has to show SalesValues of 
           CY =202201 to 202212 
           PY =202101 to 202112 

Currently in my sample data shown above dont have 2021 data. But our logics has to work for PY calculations.


Thanks,
ST

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi MohammadLoran25 ,

    Now my sample data set is limited for 2 years, Your suggestion works.
    if i plug real time data, it has apst 5 years of histirical data. In this Year legen wornt works.
    Basically, If i calculate current year sales and previous years sales in separete DAX's will solve it. The Current Year DAX formula working, Previous Year DAX formula is not working.

    Thanks,
    ST