Forum Discussion

jh292's avatar
jh292
Icon for Helper I rankHelper I
5 years ago
Solved

Calculating change in data between two report dates within the same sheet

Hi   New to powerBI, hopefully a quick fix.    I have a table that I need to make a messure for (I think) to show me the change over a period of time. Ideally that I can adapt / copy paste so I c...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi jh292 

    I build a table like yours to have a test.

    To calculate insight gathered in the last 2 days, firstly calculate the Maxdate1(2020/10/13) within last 2 days and then calculate the Maxdate2 which is before Maxdate1(2020/10/11).

    Measure:

    Measure = 
    VAR _Max2Days =
        MAXX (
            FILTER (
                ALL ( 'Table' ),
                DATEDIFF ( 'Table'[Report Date], TODAY (), DAY ) <= 2
            ),
            'Table'[Report Date]
        )
    VAR _MaxMinus =
        MAXX (
            FILTER ( ALL ( 'Table' ), 'Table'[Report Date] < _Max2Days ),
            'Table'[Report Date]
        )
    VAR _SumA =
        SUMX (
            FILTER ( 'Table', 'Table'[Report Date] = _Max2Days ),
            'Table'[Known Insight]
        )
    VAR _SumB =
        SUMX (
            FILTER ( 'Table', 'Table'[Report Date] = _MaxMinus ),
            'Table'[Known Insight]
        )
    RETURN
        _SumA - _SumB

     Result is A: 6-5=1,B:6-6=0,C:5-4=1 sum=2.

    You can download the pbix file from this link: Calculating change in data between two report dates within the same sheet

     

    Best Regards,

    Rico Zhou

     

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