Forum Discussion

DaGemsta's avatar
DaGemsta
Icon for Helper I rankHelper I
4 years ago
Solved

Total column that sum's values from different rows

Hi guys   I'm working with the following data   Index Fuel In Fuel Out OnBoard 89 2005 2005 6383 90 4900 0 11283 91 0 0 11283 92 0 1300 9983 93 0 1500 8483 ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi DaGemsta ,

     

    Please try this.

    Check = 
    VAR _ind = 'OnDemand'[Index]
    VAR _preind = _ind - 1
    VAR _onboardPreRow =
        CALCULATE (
            MAX ( 'OnDemand'[OnBoard] ),
            FILTER ( ALL ( 'OnDemand' ), 'OnDemand'[Index] = _preind )
        )
    VAR _fuelinPostrow =
        CALCULATE (
            MAX ( 'OnDemand'[Fuel In] ),
            FILTER ( ALL ( 'OnDemand' ), 'OnDemand'[Index] = _ind )
        )
    VAR _fueloutPostrow =
        CALCULATE (
            MAX ( 'OnDemand'[Fuel Out] ),
            FILTER ( ALL ( 'OnDemand' ), 'OnDemand'[Index] = _ind )
        )
    VAR _subtotal = _onboardPreRow + _fuelinPostrow - _fueloutPostrow
    RETURN
        _subtotal

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data