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.
Suppose you need to know the first working day of the month and whether today is the first working day of the month. Use these measures:
First Working Day
First Working Day of Week = VAR TodaysDate = TODAY() VAR Calendar1 = CALENDAR(DATE(YEAR(TodaysDate),1,1),DATE(YEAR(TodaysDate),12,31)) VAR Calendar2 = ADDCOLUMNS(Calendar1,"WeekNum1",WEEKNUM([Date])) VAR Calendar3 = ADDCOLUMNS(Calendar2,"WeekDay1",WEEKDAY([Date],2)) VAR TodaysWeekNum = WEEKNUM(TodaysDate) VAR Calendar4 = FILTER(Calendar3,[WeekNum1]=TodaysWeekNum&&[WeekDay1]<6) VAR FirstWorkingDay = MINX(Calendar4,[Date]) RETURN FORMAT(FirstWorkingDay,"mm/dd/yyyy")
Is First Working Day
Is First Working Day = VAR TodaysDate = TODAY() VAR Calendar1 = CALENDAR(DATE(YEAR(TodaysDate),1,1),DATE(YEAR(TodaysDate),12,31)) VAR Calendar2 = ADDCOLUMNS(Calendar1,"WeekNum1",WEEKNUM([Date])) VAR Calendar3 = ADDCOLUMNS(Calendar2,"WeekDay1",WEEKDAY([Date],2)) VAR TodaysWeekNum = WEEKNUM(TodaysDate) VAR Calendar4 = FILTER(Calendar3,[WeekNum1]=TodaysWeekNum&&[WeekDay1]<6) VAR FirstWorkingDay = MINX(Calendar4,[Date]) RETURN IF(TodaysDate=FirstWorkingDay,TRUE(),FALSE())
eyJrIjoiN2M0MjM1ZGEtNWU2ZS00OWZlLWE1YzYtNWFkOTY0N2UzMGM4IiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9
Hello @Greg_Deckler
I tried to apply your code in my PoweBi Dashboard.
Unfortunately PowerBI gives me an error in your second line (in my version of the code it is the first line) which says unexpectet token eof. I found out, that this error often comes from a problem with lower case, so I tried this, what does not work. Maybe you could help me with my problem.
Thank you for your help.
best regards
Marvin
@marvinbib - This line of code gives you an error?
VAR TodaysDate = TODAY()
Thank you for your fast reaction.
Yes, this is the line, causing the error.
As you can see in the following Screenshot.