Forum Discussion
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
| YearMonth | Sales | Qty |
202303 | 70 | 5 |
| 202302 | 65 | 4 |
| 202301 | 85 | 2 |
| 202212 | 70 | 5 |
| 202211 | 67 | 4 |
| 202210 | 85 | 5 |
202209 | 70 | 5 |
| 202208 | 65 | 4 |
| 202207 | 85 | 5 |
| 202206 | 75 | 9 |
| 202205 | 65 | 4 |
| 202204 | 83 | 5 |
| 202203 | 20 | 3 |
| 202202 | 30 | 6 |
| 202201 | 56 | 4 |
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
- MohammadLoran25
Solution Sage
Hi Anonymous ,
Putting Year in the legend section would solve your problem.
- AnonymousNot 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