Forum Discussion

JankoC's avatar
JankoC
Regular Visitor
4 years ago
Solved

Get differerence of sums between all dates in table

Hello! So I have this table (raw and image of only the first two rows below) from which I created a new table which contains sum of "SteviloSporocil" column for each "Zdravstveni dom" grouped by dat...
  • v-chenwuz-msft's avatar
    4 years ago

    Hi JankoC ,

     

    Maybe you can try this code:

    Measure =
    VAR _first =
        CALCULATE ( MIN ( 'Table'[Datum] ), ALLSELECTED ( 'Table'[Datum] ) )
    VAR _diff =
        SUM ( 'Table'[Vsota sporočil] )
            - CALCULATE ( SUM ( 'Table'[Vsota sporočil] ), PREVIOUSDAY ( 'Table'[Datum] ) )
    RETURN
        IF (
            SELECTEDVALUE ( 'Table'[Datum] ) = _first,
            CALCULATE (
                SUM ( 'Table'[Vsota sporočil] ),
                FILTER ( ALLSELECTED ( 'Table'[Datum] ), [Datum] = _first )
            ),
            _diff
        )
    

     

    Result:

     

    Pbix in the end you can refer.

    Best Regards

    Community Support Team _ chenwu zhu

     

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