The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
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
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
182 | |
81 | |
64 | |
46 | |
38 |