day to day
1 TopicDay to Day difference
Hi All, I am trying to generate a day to day difference and since I only have data on weekdays and that my data lags 1 day I am facing some issues. I have the following code: Measure_DTD = VAR vtoday = MAX('Date Table'[Date]) VAR vyesterday = IF(FORMAT(MAX('Date Table'[Date]), "DDDD")<> "Monday", MAX('Date Table'[Date])-1, MAX('Date Table'[Date])-3) VAR vtwodays = IF(FORMAT(MAX('Date Table'[Date]), "DDDD")<> "Monday", MAX('Date Table'[Date])-2, IF(FORMAT(MAX('Date Table'[Date]), "DDDD")<> "Tuesday", MAX('Date Table'[Date])-4, MAX('Date Table'[Date])-5) ) Return IF(ISBLANK([Measure_MarketValue]), BLANK(), IF(FORMAT(vtoday,"DDDD") = "Monday", CALCULATE([Measure_MarketValue],'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue],'Date Table'[Date] = vyesterday), IF(FORMAT(vtoday, "DDDD") = "Tuesday", CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vyesterday), CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vtoday) - CALCULATE([Measure_MarketValue], 'Date Table'[Date] = vyesterday) ) ) ) Which generates the following output (Sometimes I need to show the latest 3 days with data in it and sometimes I need to show the latest 10 days i.e.) As you see the oldest date does not generate the DtD (Day to Day difference) column correctly. Does anyone know how to solve this? (I also have a column named Isweekday as a filter, which is a true/false). Thank you in advance. SolleSolved4KViews0likes7Comments