Forum Discussion
Creating Sales Total dependent on date?
HI please try this and see if it works with you :
Total Sales for Week = CALCULATE(SUM([SALES]), DATESBETWEEN(DateTable[DATET], STARTOFWEEK(SELECTEDVALUE(DateTable[DATET])), ENDOFWEEK(SELECTEDVALUE(DateTable[DATET]))))
This measure uses the DATESBETWEEN function to filter the sales by the week that contains the selected date, as determined by the STARTOFWEEK and ENDOFWEEK functions.
Total Sales for Month = CALCULATE(SUM([SALES]), DATESBETWEEN(DateTable[DATET], STARTOFMONTH(SELECTEDVALUE(DateTable[DATET])), ENDOFMONTH(SELECTEDVALUE(DateTable[DATET]))))
This measure uses the DATESBETWEEN function to filter the sales by the month that contains the selected date, as determined by the STARTOFMONTH and ENDOFMONTH functions.
Thanks but PowerBI says "Failed to resolve name 'STARTOFWEEK', its not a valid table, variable or function name