Forum Discussion
Anonymous
3 years agoNot applicable
Excel Formula to Dax
I have sample data in Excel for few years . year value 2020 100 2021 120 2022 150 Syntax: ((currentyear)/(previousyear))^(1-n))-1 Excel used the belo...
- 3 years ago
hi Anonymous
seems you are calculating compound annual growth rate.
i tried the following, for your reference.
1) expand your dataset and transpose it to:
Year Value 2017 40 2018 50 2019 80 2020 100 2021 120 2022 150 2) add a calculate table for the n parameter, like:
n = SELECTCOLUMNS( GENERATESERIES(1,5), "n", [Value] )3) plot a slicer with n[n] column and a table visual with year column and a measure like:
CAGA% = VAR _currentyear = MAX(data[Year]) VAR _n = SELECTEDVALUE(n[n]) VAR _firstyear = _currentyear-_n VAR rate = DIVIDE( SUM(data[value]), CALCULATE( SUM(data[value]), data[Year]=_currentyear-_n ) )^(1/_n) -1 RETURN IF(rate<>-1, rate, "")it worked like:
verified the calculation with Excel formula:
Anonymous
3 years agoNot applicable
FreemanZ thank you so much ... its working