I have to show the previous day sale along with the current sale. The problem is that the day which does not have previous day sale, that row is getting skipped. I am using the below DAX function :
SumInRange =
var sel = selectedvalue('Table'[Date])
return
CALCULATE(SUMX(DISTINCT('Table'[Date]),CALCULATE(MAX('Table'[Sale]))),FILTER(all('Table'),'Table'[Date] = sel -1))
To replicate the scenario first step is to create Dim Date table using - >
Dim Date = GENERATESERIES(date(2019,01,01),date(2019,12,31),1)
second Step is to create DataTable ->
Table = DATATABLE("Date",DATETIME,"Flag1",STRING,"Flag2",STRING,"Sale",INTEGER,{
{"8/1/2019","True","True",200},
{"8/2/2019","False","True",80},
{"8/2/2019","False","True",80},
{"8/2/2019","False","True",80},
{"8/2/2019","False","True",80},
{"8/2/2019","False","True",80},
{"9/3/2019","False","True",60},
{"9/4/2019","False","True",10},
{"9/5/2019","False","True",100},
{"9/6/2019","False","True",30},
{"9/7/2019","False","True",60},
{"9/8/2019","False","False",150},
{"9/9/2019","False","False",80},
{"9/10/2019","False","False",90},
{"9/11/2019","False","False",30},
{"9/12/2019","False","False",20},
{"10/13/2019","False","True",50},
{"10/14/2019","False","True",60},
{"10/15/2019",BLANK(),BLANK(),BLANK()},
{"10/16/2019",BLANK(),BLANK(),BLANK()}
})
3rd Step - create a relation between these tables on date column
4th step - create Measure using -
SumInRange =
var sel = selectedvalue('Table'[Date])
return
CALCULATE(SUMX(DISTINCT('Table'[Date]),CALCULATE(MAX('Table'[Sale]))),FILTER(all('Table'),'Table'[Date] = sel -1))
Output of this is attached as the screenshot. You will observe that the date that does not have previous day sale is getting omitted like - 08/01/2019. Row for this date is getting skipped because it does not have previous day sale? How to get the skipped row back again giving 0 sale for previous date?