Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Nun
Resolver I
Resolver I

Assign to the first work day the value of WD1, second working day = WD2..

Hello,

 

I created a calendar table 

calendar = CALENDAR(DATE(2021,01,02),DATE(2021,12,31))
and columns:
WeekN = WEEKNUM([Date])
IsWorkingDay = IF(WEEKDAY('Calendar'[Date],2)>5,0,IF('calendar'[Date] = DATE(2021,04,02) || 'calendar'[Date] = DATE(2021,04,02),0,1))
but I need to assign to the first working day of the month (for all the months) the value WD1, to the second the value of WD2.
so for example, in January 2021 the first working day is 04.01.2021 (which is Monday) and I need to assign WD1, in April the first working (to be assigned WD1) is 01.04.2021 (which is Friday) and the second working day (to be assigned WD2) is 05.04.2021 (which is Tue.)
Thanks a lot for supporting!
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Nun 

Add a YearMonth column when you create WEEKDAY table.

WEEKDAY = ADDCOLUMNS(CALENDAR(DATE(2021,01,02),DATE(2021,12,31)),"YearMonth",YEAR([Date])*100+MONTH([Date]))

Then build try my code.

Flag = 
VAR _WeekDay = WEEKDAY('WEEKDAY'[Date],2)
VAR _Rank = IF(_WeekDay in {6,7},BLANK(),1)
RETURN
_Rank
WD = 
VAR _WeekDay = WEEKDAY('WEEKDAY'[Date],2)
VAR _Result = IF(_WeekDay in {6,7},BLANK(),"WD"&""&CALCULATE(SUM('WEEKDAY'[Flag]),FILTER('WEEKDAY','WEEKDAY'[YearMonth] = EARLIER('WEEKDAY'[YearMonth])&&'WEEKDAY'[Date]<=EARLIER('WEEKDAY'[Date]))))
RETURN
_Result

Result:

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Nun , I think you need work day number of month, see if these columns can help

 

Work Day = if(WEEKDAY([Date],2)>=6,0,1)
Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])

Work day of month = Sumx(filter(Date, [Month year] = earlier([Month year])),[Work Day])
Work day of week = Sumx(filter(Date, [Weekyear] = earlier([Weekyear])),[Work Day])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak , thanks for supporting.

I checked a previous post from you 🙂 which is high appreciated, I created the columns described

Nun_1-1625038077306.png

but how I can assign "WD1" to the first working day (in January is 04.01.2021 ((Monday)), in April is 01.04.201 (Thu), as well WD2..?

Thank you in advance!

 

Anonymous
Not applicable

Hi @Nun 

Add a YearMonth column when you create WEEKDAY table.

WEEKDAY = ADDCOLUMNS(CALENDAR(DATE(2021,01,02),DATE(2021,12,31)),"YearMonth",YEAR([Date])*100+MONTH([Date]))

Then build try my code.

Flag = 
VAR _WeekDay = WEEKDAY('WEEKDAY'[Date],2)
VAR _Rank = IF(_WeekDay in {6,7},BLANK(),1)
RETURN
_Rank
WD = 
VAR _WeekDay = WEEKDAY('WEEKDAY'[Date],2)
VAR _Result = IF(_WeekDay in {6,7},BLANK(),"WD"&""&CALCULATE(SUM('WEEKDAY'[Flag]),FILTER('WEEKDAY','WEEKDAY'[YearMonth] = EARLIER('WEEKDAY'[YearMonth])&&'WEEKDAY'[Date]<=EARLIER('WEEKDAY'[Date]))))
RETURN
_Result

Result:

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Thanks a lot!!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors