Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX CALCULATE with conditional DATEADD

Good Day.   I currently have two working measusres. The first shows total sales, and the second shows the total sales from the previous day:   MTotalSales = SUMX(AllSales,AllSales[Price]*AllSale...
  • Anonymous's avatar
    Anonymous
    5 years ago

    I ended up resolving the problem. Instead of keeping a running tabular total, I directly targeted the KPI.


    Using, variables, I was able to pull off what I needed:


    MPreviousWeekDaySales =
    VAR ThreeDaysRange = FILTER(AllDates,AllDates[Date] = TODAY() - 3)
    VAR OneDayRange = FILTER(AllDates,AllDates[Date] = TODAY() - 1)
    RETURN IF(WEEKDAY(TODAY()) = 2,SUMX(ThreeDaysRange,[MTotalSales]),SUMX(OneDayRange,[MTotalSales]))