Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to calculate Average growth rate over time Dax query

Let say
Number of milk cans sold by the company in the past four years:

2018 = 350
2019 = 450
2020 = 500
2021 = 650

Calculate the company's average annual growth rate.

So, if the present value is 650, the past value is 350 and the number of years is 4, you get:

Growth rate after 2018: (450 - 350) / 350 x 100 = 28.57%

Growth rate after 2019: (500 - 450) / 450 x 100 = 11.11%

Growth rate after 2020: (650 - 500) / 500 x 100 = 30%

Average growth rate over time = (28.57% + 11.11% + 30%) / 3 = 23.22% per year

Im struggling to get this in dax query .
Suggest a method to get Average growth rate over time

 

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Using a separate Year/Date table

 

measures

 

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

Avg diff %

 

Rolling 3 = calculate(AverageX(Values('Date'[Year]),[diff%]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,Year))

 

or

 

CALCULATE(AverageX(Values('Date'[Year]),[diff%]),filter(ALL('Date'),'Date'[Year]>=max('Date'[Year])-3 && 'Date'[Year]<=max('Date'[Year])))

Anonymous
Not applicable

Hi,

Used the same example mentioned in question. It shows the present year value instead of average of total diff percent.
Measure i used is

Avg growth rate =
var This_Year = CALCULATE(sum('Table'[Sales]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
var Last_Year = CALCULATE(sum('Table'[Sales]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
var diff = This_Year-Last_Year
var diffpercent = divide(diff,Last_Year)*100
return
CALCULATE(AverageX(Values('Date'[Year]),diffpercent),filter(ALL('Date'),'Date'[Year]>=max('Date'[Year])-3 && 'Date'[Year]<=max('Date'[Year])))

Catlie_0-1648723752211.png

 

Anonymous
Not applicable

Hi,
Thanks a lot for the quick reply & query.
I'm going to check now.

If possible could you explain the Rolling 3 dax .
How it will dynamically calculate rate for each year and average the all three

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.