Forum Discussion
Creating Sales Total dependent on date?
Hello There,
I have a daily sales Column (lets call it [DATE] and [SALES] which is tied neatly to a date table which has days [DATET], week number [WEEKNUMBER] , month [MONTHNUMBER] etc.
Basically what I want to do is say I pick 24th Feburary 2023 (A friday for future readers), how would I construct a measure to calculate how many sales would have occured for that WEEK (Week 😎 and for that MONTH (feburary)
Many thanks
B
2 Replies
- bhelouResponsive Resident
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.- BugmanJHelper V
Thanks but PowerBI says "Failed to resolve name 'STARTOFWEEK', its not a valid table, variable or function name