Forum Discussion

LFM's avatar
LFM
Helper III
2 years ago
Solved

Calculating previous days values

Im trying to calculate previous days exposure for the measure called "prevous days exposure_mwh". It should be the sum of exposure for the last day. I dont get any values as seen in the pictures. What is wrong wilth the calculation?

  • LFM You are using CALCULATE and TI functions is what is primarily wrong. Do this instead:

    Measure =
      VAR __Date = MAX('NPOSC'[date]) - 1
      VAR __Table = FILTER( ALL('NPOSC'), [date] = __Date )
      VAR __Result = SUMX( __Table, [exposure_mwh] )
    RETURN
      __Result

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    LFM You are using CALCULATE and TI functions is what is primarily wrong. Do this instead:

    Measure =
      VAR __Date = MAX('NPOSC'[date]) - 1
      VAR __Table = FILTER( ALL('NPOSC'), [date] = __Date )
      VAR __Result = SUMX( __Table, [exposure_mwh] )
    RETURN
      __Result