Forum Discussion

Nerf_Herder's avatar
Nerf_Herder
Frequent Visitor
3 years ago
Solved

Using DIVIDE() with LAG()

I'm hoping you good folk can help as I feel like I've hit a wall.   I've created a calculated table with two columns 'Date' & 'Costs'. I'm trying to create a new column for the growth, from the pre...
  • Anonymous's avatar
    Anonymous
    3 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.