Forum Discussion
Excel Formula to Dax
- 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:
FreemanZ how to use here Date Column instead of Year .. year number format.when i change it to Date . value is blank
Var _currentyear=MAX(data[year])
VAR _currentyear = MAX(data[Year])
could you post some sample data?
- Anonymous3 years agoNot applicable
FreemanZ please find thje sample data . i have data range 2019 to 2025 ..
REGION DATE YEARS VALUE
EAST 01-01-2019 2019 454
WEST 01-02-2019 2019 954
EAST 01-03-2019 2019 354
NORTH 01-04-2019 2019 554
SOUTH 01-05-2019 2019 654
WEST 01-06-2019 2019 454
WEST 01-07-2019 2019 454
EAST 01-08-2019 2019 354
NORTH 01-09-2019 2019 554
WEST 01-10-2019 2019 654
EAST 01-11-2019 2019 454
WEST 01-12-2019 2019 954
EAST 01-01-2020 2020 454
WEST 01-02-2020 2020 954
EAST 01-03-2020 2020 354
NORTH 01-04-2020 2020 554
SOUTH 01-05-2020 2020 654
WEST 01-06-2020 2020 454
WEST 01-07-2020 2020 454
EAST 01-08-2020 2020 354
NORTH 01-09-2020 2020 554
WEST 01-10-2020 2020 654
EAST 01-11-2020 2020 454
WEST 01-12-2020 2020 954