MikeMir
MikeMir

Reputation: 13

Calculating last week's data does not work

I have a table with a date column to identify the most recent date (DayDate), and an added column with last week's date (Prev7DayDate). For some reason, my Measure does not work and displays blank value when I want to calculate previous week's total:

TotPrevWk = VAR latest_prev_wk_date = CALCULATE(MAX('tblA'[Prev7DayDate]), ALLSELECTED('tblA'))

RETURN CALCULATE(SUM('tblA'[TotACs]), FILTER('tblA', 'tblA'[DayDate] = latest_prev_wk_date && 'tblA'[P]="NO"))

Upvotes: 1

Views: 37

Answers (1)

Sam Nseir
Sam Nseir

Reputation: 12111

You'll need to use ALL to return the full table outside of what is filtered. Note the ALL in the FILTER below.

TotPrevWk =
  VAR latest_prev_wk_date = CALCULATE(MAX('tblA'[Prev7DayDate]), ALLSELECTED('tblA'))

  RETURN CALCULATE(SUM('tblA'[TotACs]), FILTER(ALL('tblA'), 'tblA'[DayDate] = latest_prev_wk_date && 'tblA'[P]="NO"))

Upvotes: 0

Related Questions