Forum Discussion

MarkDGaal's avatar
MarkDGaal
Helper III
10 years ago
Solved

Measure to Calculate Difference vs. Previous Period

Hello, I am pulling from a Data Source that appends new data once or twice a week (the duration between appending data is not consistent). When new data is appended to the table it is signified by a ...
  • jahida's avatar
    jahida
    10 years ago

    Here's my result:

     

    There's a 20k discrepency in one spot but I doubt that's something wrong with the formulas, seems like a data discrepency... Other than that matches perfectly. If you want the last column to appear blank, here's a slightly adapted LastExtr formula:

     

    LastExtr =
    Var SecondToLastOrFirst = IF(HASONEVALUE(Sheet1[Extract Date and Time]), CALCULATE(MAX(Sheet1[Extract Date and Time]), FILTER(ALL(Sheet1[Extract Date and Time]), Sheet1[Extract Date and Time] < MAX(Sheet1[Extract Date and Time]))), MIN(Sheet1[Extract Date and Time])
    )
    return IF(SecondToLastOrFirst < CALCULATE(MIN(Sheet1[Extract Date and Time]), ALLSELECTED(Sheet1[Extract Date and Time])), BLANK(), CALCULATE(SUM(Sheet1[Value]), ALL(Sheet1[Extract Date and Time]), Sheet1[Extract Date and Time] = SecondToLastOrFirst))

     

    diff01 =
    VAR Last = CALCULATE( SUM( Table2[Value] ), FILTER( Table2, Table2[Extract Date and Time] = MAX( Table2[Extract Date and Time]) ) )

    return
    if([LastExtr] & "" = BLANK(), BLANK(), Last - [LastExtr])

     

    Then diff01 holds the change numbers you want.

     

    And then you'd have to set the Extract Date and Time field to "Show items with no data". Here's that result: