Forum Discussion

tomislav_mi's avatar
tomislav_mi
Helper II
6 years ago
Solved

Calculating a difference between two rows as a calculated column

Hey guys, Could you please help me out to get the difference between rows as a calculated column considering a few parameters? I would need to calculate the difference between sales, having in ...
  • Greg_Deckler's avatar
    6 years ago

    Probably something like below. PBIX attached.

     

    Column = 
        VAR __Previous = 
            MAXX(
                FILTER(
                    ALL('Table'),
                    [Account] = EARLIER([Account]) &&
                        [Date] < EARLIER([Date])
                ),
                [Date]
            )
    RETURN
        [Sales] - 
        MAXX(
            FILTER(
                ALL('Table'),
                [Account] = EARLIER([Account]) &&
                [Date] = __Previous
            ),
            [Sales]
        )