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
enghone007
New Member

Calculate CAGR% for Moving Annual Total Dynamic formula

Hi everyone,

 

I have been trying to find an answer for the CAGR calculation that I need but I wasn't able to find a solution. So I am hoping someone can help me. I used the following video to build by Dynamic CAGR% model but it is not working for what I need.

https://www.youtube.com/watch?v=IUdsztn62aA

 

Please let me explain

I want to calculate CAGR for moving 12 months. For example, say the latest data period I have is till April 2022, I want to calculate CAGR using starting year April 2019 or April 2018. How do I make the start year and month to be dynamic based on the end year and month? And then the next following month in May, I want to use May 2022 MAT period.

Do I need a MAT year column in my date table? If so, how do I write M query for that?

 

Any solution is welcome. Appreciate your help. Thank you. 

4 REPLIES 4
enghone09
Frequent Visitor

Thank you for your help. but Mquery doesn't give me the period that I need. So for example

May-2021

Jun-2021

Jul-2021

Aug-2021

...

...

...

April 2022

 

The whole twelve months I want the column to show "MAT April 2022". And then when May 2022 data is available, i want the data to go 12 months back. 

 

 

Hi, @enghone09 @enghone007 

Please change M codes as below:
Period Year:

=Text.From(Date.Year(Date.AddMonths([Date], 1 + (Date.Month(DateTime.LocalNow())))))

Dynamic Period:

=Text.Combine(
      {
        "MAT",
        Text.From(Date.Year(Date.AddMonths([Date], 1 + (Date.Month(DateTime.LocalNow()))))),
        Date.MonthName(Date.AddMonths(DateTime.LocalNow(), - 1))
      },
      " "
    )

(MAT May 2022)

veasonfmsft_0-1654583032331.png

Then replace the fields in my original Dax formulas with these new fields.

Please check my sample file for more details.

veasonfmsft_1-1654583392704.png

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much. It definitely help solved the problem.

v-easonf-msft
Community Support
Community Support

Hi, @enghone007 

Please try the following M query to offset your original field ‘Year’ based on the current month.:

=Date.Year(Date.AddMonths([Date], -(Date.Month(DateTime.LocalNow()))))

veasonfmsft_1-1653907307136.png

Then you can replace your original filed 'Year' with new field 'Period' in your model.

Meaure:

Ending Period = CALCULATE(MAX('Revenue'[Dynamic Period] ),ALL('Revenue'[Dynamic Period]))
Ending Period Value = CALCULATE([Total Revenue],FILTER(ALL(Revenue[Dynamic Period]),Revenue[Dynamic Period]=Revenue[Ending Period]))
No.of Periods -1 = [Ending Period]-VALUES('Period Table'[Dynamic Period])
Starting Period Value = CALCULATE('Period Table'[Total Revenue],FILTER(ALL(Revenue[Dynamic Period]),Revenue[Dynamic Period]= VALUES('Period Table'[Dynamic Period]) ))
CAGR = ([Ending Period Value]/[Starting Period Value])^(1/[No.of Periods -1])-1

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

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.

Top Solution Authors