In this blog, you will learn how to calculate the year-over-year growth percentage in Power BI using a DAX formula.
Let’s get started
Step-1: Import the sample dataset mentioned below:
SalesData
Date | Sales |
01-01-2022 | 320 |
01-02-2022 | 350 |
01-03-2022 | 380 |
01-04-2022 | 400 |
01-05-2022 | 420 |
01-06-2022 | 450 |
01-07-2022 | 480 |
01-08-2022 | 500 |
01-09-2022 | 530 |
01-10-2022 | 560 |
01-11-2022 | 590 |
01-12-2022 | 620 |
01-01-2023 | 650 |
01-02-2023 | 680 |
01-03-2023 | 710 |
01-04-2023 | 740 |
01-05-2023 | 770 |
01-06-2023 | 800 |
01-07-2023 | 830 |
01-08-2023 | 860 |
01-09-2023 | 890 |
01-10-2023 | 920 |
01-11-2023 | 950 |
01-12-2023 | 980 |
After this, create a calendar table using the following DAX formula:
Go to Modeling tab> choose ‘write a DAX expression to create a table’
DateTable = CALENDAR(MIN('SalesData'[Date]), MAX('SalesData'[Date]))
Step-2: Create a relationship between the 'SalesData'
and 'DateTable'
datasets.
Step-3: Now, To calculate Year-over-Year (YoY) growth in Power BI, you can use the following DAX formula. This formula calculates the percentage change in a measure compared to the same period in the previous year.
Total Sales = SUM('SalesData'[Sales])
YoYGrowth = VAR CurrentYearSales = [Total Sales] VAR PreviousYearSales = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('DateTable'[Date])) RETURN IF( PreviousYearSales <> 0, (CurrentYearSales - PreviousYearSales) / PreviousYearSales*100, BLANK() )
Step-4: Now you can see the year-over-year growth percentage change in the screenshot below.
Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome.