Forum Discussion
Using DIVIDE() with LAG()
- Anonymous3 years ago
Hi Nerf_Herder ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) Click "transform data" to enter the power query editor, change the data type of the [Costs] column to "Decimal number" type, sort the date column in ascending order, and then add the index column.
(3)Click "Close and Apply" to go back to desktop and create a calculated column.
Column = var _current='Table'[Costs] var _prev=CALCULATE(SUM('Table'[Costs]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1)) return DIVIDE(_current-_prev,_prev,0)(4) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Nerf_Herder ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) Click "transform data" to enter the power query editor, change the data type of the [Costs] column to "Decimal number" type, sort the date column in ascending order, and then add the index column.
(3)Click "Close and Apply" to go back to desktop and create a calculated column.
Column =
var _current='Table'[Costs]
var _prev=CALCULATE(SUM('Table'[Costs]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
return DIVIDE(_current-_prev,_prev,0)
(4) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Nerf_Herder3 years agoFrequent Visitor
Hi Anonymous,
That worked a treat, thank you so much for your help!
Cheers,
Ian.