Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello folks,
I have a very simple calendar table which I want to enrich with holiday information in the "WorkingDay" column. For this I have pulled in a table from the internet which has the public holiday information, containing a date column and a description column. It looks so easy but I can't get it to work.
I want to have the boolean expression in "WorkingDay" taking the holidays into account.
Any ideas?
I thought adding a variable of the holiday dates and calling this in a NOT [Date] in {holidays} function would do it, but no...
Calendar =
GENERATE(
CALENDARAUTO(),
var YYYY =
YEAR( [Date] )
var MMM =
MONTH( [Date] )
var Holidays =
{DISTINCT(Feiertage[Column2])}
return
ROW(
"Year", YYYY,
"Month", FORMAT( [Date] , "mmmm" ),
"Month No", MMM,
"Weekday", FORMAT( [Date], "dddd"),
"Weekday No", WEEKDAY( [Date], 2),
"WorkingDay", NOT (
WEEKDAY( [Date], 2) in {6,7}
)
)
)
Solved! Go to Solution.
@hashtag_pete How about:
Calendar =
GENERATE(
CALENDARAUTO(),
var YYYY =
YEAR( [Date] )
var MMM =
MONTH( [Date] )
var Holidays =
{DISTINCT(Feiertage[Column2])}
return
ROW(
"Year", YYYY,
"Month", FORMAT( [Date] , "mmmm" ),
"Month No", MMM,
"Weekday", FORMAT( [Date], "dddd"),
"Weekday No", WEEKDAY( [Date], 2),
"WorkingDay", NOT (
WEEKDAY( [Date], 2) in {6,7}
) && NOT(CONTAINS(Holidays,[Column2],[Date]))
)
)
@hashtag_pete Well, I actually think that this is the better solution (below). I think that it is working because it ends up referencing a column in an actual table, [Column2] because the Holidays variable would have a column name of [Value] and not [Column2]. So probably a bit of luck. However, if you do it this way is better:
Calendar =
VAR Holidays = DISTINCT(Feiertage[Column2])
RETURN
GENERATE(
CALENDARAUTO(),
var YYYY =
YEAR( [Date] )
var MMM =
MONTH( [Date] )
return
ROW(
"Year", YYYY,
"Month", FORMAT( [Date] , "mmmm" ),
"Month No", MMM,
"Weekday", FORMAT( [Date], "dddd"),
"Weekday No", WEEKDAY( [Date], 2),
"WorkingDay", NOT (
WEEKDAY( [Date], 2) in {6,7}
) && NOT([Date] in Holidays)
)
)
@hashtag_pete Maybe:
Calendar =
GENERATE(
CALENDARAUTO(),
var YYYY =
YEAR( [Date] )
var MMM =
MONTH( [Date] )
var Holidays =
{DISTINCT(Feiertage[Column2])}
return
ROW(
"Year", YYYY,
"Month", FORMAT( [Date] , "mmmm" ),
"Month No", MMM,
"Weekday", FORMAT( [Date], "dddd"),
"Weekday No", WEEKDAY( [Date], 2),
"WorkingDay", NOT (
WEEKDAY( [Date], 2) in {6,7}
) && NOT([Date] in Holidays)
)
)
I gave this a try but received this error:
<pi>A table of multiple values was supplied where a single value was expected.</pi>
I even tried varing in making the holidays a list, but it doesn't seem to matter if I set the {} in the variable or in the function...
@hashtag_pete How about:
Calendar =
GENERATE(
CALENDARAUTO(),
var YYYY =
YEAR( [Date] )
var MMM =
MONTH( [Date] )
var Holidays =
{DISTINCT(Feiertage[Column2])}
return
ROW(
"Year", YYYY,
"Month", FORMAT( [Date] , "mmmm" ),
"Month No", MMM,
"Weekday", FORMAT( [Date], "dddd"),
"Weekday No", WEEKDAY( [Date], 2),
"WorkingDay", NOT (
WEEKDAY( [Date], 2) in {6,7}
) && NOT(CONTAINS(Holidays,[Column2],[Date]))
)
)
@Greg_Deckler not quite sure why it works but it does 😄
I thought that the IN operator is just syntax sugar for contains, but obviously in the background something is working differently. Thanks for pointing that one out
@hashtag_pete Well, I actually think that this is the better solution (below). I think that it is working because it ends up referencing a column in an actual table, [Column2] because the Holidays variable would have a column name of [Value] and not [Column2]. So probably a bit of luck. However, if you do it this way is better:
Calendar =
VAR Holidays = DISTINCT(Feiertage[Column2])
RETURN
GENERATE(
CALENDARAUTO(),
var YYYY =
YEAR( [Date] )
var MMM =
MONTH( [Date] )
return
ROW(
"Year", YYYY,
"Month", FORMAT( [Date] , "mmmm" ),
"Month No", MMM,
"Weekday", FORMAT( [Date], "dddd"),
"Weekday No", WEEKDAY( [Date], 2),
"WorkingDay", NOT (
WEEKDAY( [Date], 2) in {6,7}
) && NOT([Date] in Holidays)
)
)
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
86 | |
81 | |
70 | |
49 |
User | Count |
---|---|
143 | |
124 | |
107 | |
60 | |
55 |