Search code examples
powerbidaxdata-analysispowerbi-desktopmeasure

Dax calculate a metric for another day in the calendar table


I have a table with a date column and a money column:

Thedate CashCollected
2039-12-28  100
2039-12-27  200
2039-12-26  300
2039-12-25  400
2039-12-24  500
2039-12-23  600
2039-12-22  700
2039-12-21  800

and then I have the date table with the date and the previous working day calculated following some specific conditions:

TheDate  PrevItWorkDay
2039-12-28  2039-12-27
2039-12-27  2039-12-23
2039-12-26  2039-12-23
2039-12-25  2039-12-23
2039-12-24  2039-12-23
2039-12-23  2039-12-22
2039-12-22  2039-12-21
2039-12-21  2039-12-20

I would like to calculate in DAX a measure which gives me the sum of cash collected for the previous working day in the date table:

TheDate  PrevItWorkDay
2039-12-28  200
2039-12-27  600
2039-12-26  600
2039-12-25  600
2039-12-24  600
2039-12-23  700
2039-12-22  800
2039-12-21  

How can I do this?


Solution

  • PrevWorkingDaySum = 
    CALCULATE( 
       SUM(TransactionTable[CashCollected]) ,  
       TransactionTable[Thedate]= SELECTEDVALUE(DateTable[PrevItWorkDay])
    ) 
    

    enter image description here