Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
05-30-2022 08:44 AM - last edited 05-30-2022 08:46 AM
To have a calendar that has a week start date that can start on any weekday
The solution should use a weekday as a variable and should create a calendar that can have a start date on a given weekday.
_weekday is variable, where one needs to provide values from 1 to 7
Code
Date =
var _weekday =7 //Sunday- 1, Monday -2 , Tuesday -3, Wednesday -4, Thursday -5, Friday -6, Saturday -7
var _left = 7-_weekday
var _tab = ADDCOLUMNS(CALENDAR(date(2018,1,1),Date(2022,12,31)),"Month Year",format([Date],"MMM-YYYY"),
"Weekday" , WEEKDAY([date]),
"Week Start Date Sunday" , [Date] + -1*WEEKDAY([Date])+1,
"Week End Date Sunday" , [Date] + -1*WEEKDAY([Date])+7,
"Week Start Date" , [Date] + -1*if(WEEKDAY([Date])<_weekday,WEEKDAY([Date],1)+ _left,WEEKDAY([Date],1)-1* _weekday),
"Week End Date" , ([Date] + -1*if(WEEKDAY([Date])<_weekday,WEEKDAY([Date],1)+ _left,WEEKDAY([Date],1)-1* _weekday))+6
)
return _tab
Download the file given below.
Click Here to access all my blogs and videos in a jiffy via an exclusive visual glossary using Power BI.
Please like, share, and comment on these. Your suggestions on improvement, challenges, and new topics will help me explore more.
You Can watch my Power BI Tutorial Series on My Channel, Subscribe, Like, and share