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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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])

@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!

 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.