Toby
Toby

Reputation: 145

Power BI Previous x Days

I have the below table in Power BI.

 rundate   checktypeid    state    value    DOW
  6/11/21    1             ALL      250     Friday
  6/10/21    1             ALL      240     Thursday
  6/10/21    2             FL       300     Thursday
  6/10/21    2             FL       310     Thursday
  6/4/21     1             ALL      400     Friday
  6/3/21     2             FL       410     Friday

I need a view of the previous week day, something like this... grouping by checktypeid and state

  rundate   checktypeid    state    value    DOW       Last_DOW_value
  6/11/21    1             ALL      250     Friday       400
  6/10/21    1             ALL      240     Thursday    
  6/10/21    2             FL       300     Thursday     410
  6/4/21     1             ALL      400     Friday      
  6/3/21     2             FL       410     Friday      

I've tried something like below as a measure

Last_DOW_value = CALCULATE(sum(tableA[value]),tableA[CHECK_TYPE_ID],tableA[State],PREVIOUSDAY(AutoDialerDaily[run_dt])-6)

Capture the previous week's value (compare Monday to Monday, Tuesday to Tuesday, etc) Keeping in mind I have multiple same dates for different checktypeid and state.

Upvotes: 0

Views: 55

Answers (1)

msta42a
msta42a

Reputation: 3741

Look at this measure:

Last_DOW_value = CALCULATE(sum(tableA[value]), FILTER(ALL(tableA), tableA[state] = SELECTEDVALUE(tableA[state]) && tableA[checktypeid] = SELECTEDVALUE(tableA[checktypeid]) && tableA[rundate] = SELECTEDVALUE(tableA[rundate])-7 ))

Upvotes: 1

Related Questions