Forum Discussion

nasbkrv's avatar
nasbkrv
Regular Visitor
6 years ago
Solved

Previous row value formula

Hi Team, I read this post: https://community.powerbi.com/t5/Desktop/Calculated-column-From-To-formula/td-p/1274376 and it works for me too, but not for every row. The given example is: And...
  • Icey's avatar
    6 years ago

    Hi nasbkrv ,

     

    Please add an Index column in Power Query Editor first. And then, create calculated columns like so:

    From =
    CALCULATE (
        SUM ( 'Table'[Metric] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[ID] ),
            'Table'[Index] < EARLIER ( 'Table'[Index] )
        )
    ) + 0
    
    To =
    'Table'[From] + 'Table'[Metric]
    

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.