Forum Discussion
Date Period - This week
Good Evening
Hope you are well
I have a date period slicer on my PBIX and i need to add two more values.
1. This week
2. last week.
Below is a picture of ny current visual
i have used the below dax as a measure
Anonymous here is an example on how you can add this and prev week:
Date Period = VAR __today = TODAY() VAR __thisWeek = CALENDAR ( __today - ( WEEKDAY( __today ) - 1 ), __today + 7 - ( WEEKDAY ( __today ) ) ) VAR __prevWeek = CALENDAR ( MINX ( __thisWeek, [Date] ) - 7, MAXX ( __thisWeek, [Date] ) - 7 ) RETURN UNION ( ADDCOLUMNS ( { __today }, "Type", "Today", "Order", 1 ), ADDCOLUMNS ( { __today - 1 }, "Type", "Yesterday", "Order", 2 ), ADDCOLUMNS ( __thisWeek, "Type", "This Week", "Order", 3 ), ADDCOLUMNS ( __prevWeek, "Type", "Prev Week", "Order", 4 ) )✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
3 Replies
- parry2kSuper User
Anonymous here is an example on how you can add this and prev week:
Date Period = VAR __today = TODAY() VAR __thisWeek = CALENDAR ( __today - ( WEEKDAY( __today ) - 1 ), __today + 7 - ( WEEKDAY ( __today ) ) ) VAR __prevWeek = CALENDAR ( MINX ( __thisWeek, [Date] ) - 7, MAXX ( __thisWeek, [Date] ) - 7 ) RETURN UNION ( ADDCOLUMNS ( { __today }, "Type", "Today", "Order", 1 ), ADDCOLUMNS ( { __today - 1 }, "Type", "Yesterday", "Order", 2 ), ADDCOLUMNS ( __thisWeek, "Type", "This Week", "Order", 3 ), ADDCOLUMNS ( __prevWeek, "Type", "Prev Week", "Order", 4 ) )✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- AnonymousNot applicable
hi parry2k
i have just used my report and filtered to This month, its returning no data as it thinks we are already in October. From the above code, can you see the reason why?
last month only returns 1/9/21
- AnonymousNot applicable
parry2k thank you for your quick reply. this has worked out great .