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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
RobertBech
New Member

Merging holiday table with date table

Hi everyone,

 

I have 2 tables:

 

  • A table of holidays
    RobertBech_0-1717079299530.png
  • A date table

I would like to merge the two tables to get a table that shows, for each day, who is on holiday:

RobertBech_1-1717079372824.png

 

Could you please help me to find a solution ?
Thank you in advance !

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @RobertBech, here you go:

 

Result

dufoq3_0-1717080692838.png

let
    Table_Holidays = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIw1AUiIxMg09AAyozViVZyAslZIOQskeScUfUZmCLJuaDJGSLJgewzNMdiZiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Employee = _t, #"Start Date" = _t, #"End Date" = _t]),
    Table_Dates = Table.FromList(List.Dates(#date(2024,1,1), 20, #duration(1,0,0,0)), (x)=> {x}, type table[Date=date]),
    ChangedTypeTable_Holidays = Table.TransformColumnTypes(Table_Holidays, {{"Start Date", type date}, {"End Date", type date}}, "sk-SK"),
    Ad_Dates = Table.AddColumn(ChangedTypeTable_Holidays, "Dates", each List.Dates([Start Date], Duration.TotalDays([End Date]-[Start Date])+1, #duration(1,0,0,0)), type list),
    GroupedRowsBuffer = Table.Buffer(Table.Group(Ad_Dates, {"Employee"}, {{"Dates", each List.Combine([Dates]), type table}})),
    TransformTable_Dates = List.Accumulate(
        GroupedRowsBuffer[Employee],
        Table_Dates,
        (s,c)=> Table.AddColumn(s, c, each 
                    [ a = List.Combine(Table.SelectRows(GroupedRowsBuffer, (x)=> x[Employee] = c)[Dates]),
                      b = if List.Contains(a, [Date]) then 1 else 0
                    ][b], Int64.Type) )
in
    TransformTable_Dates

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

3 REPLIES 3
dufoq3
Super User
Super User

Hi @RobertBech, here you go:

 

Result

dufoq3_0-1717080692838.png

let
    Table_Holidays = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIw1AUiIxMg09AAyozViVZyAslZIOQskeScUfUZmCLJuaDJGSLJgewzNMdiZiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Employee = _t, #"Start Date" = _t, #"End Date" = _t]),
    Table_Dates = Table.FromList(List.Dates(#date(2024,1,1), 20, #duration(1,0,0,0)), (x)=> {x}, type table[Date=date]),
    ChangedTypeTable_Holidays = Table.TransformColumnTypes(Table_Holidays, {{"Start Date", type date}, {"End Date", type date}}, "sk-SK"),
    Ad_Dates = Table.AddColumn(ChangedTypeTable_Holidays, "Dates", each List.Dates([Start Date], Duration.TotalDays([End Date]-[Start Date])+1, #duration(1,0,0,0)), type list),
    GroupedRowsBuffer = Table.Buffer(Table.Group(Ad_Dates, {"Employee"}, {{"Dates", each List.Combine([Dates]), type table}})),
    TransformTable_Dates = List.Accumulate(
        GroupedRowsBuffer[Employee],
        Table_Dates,
        (s,c)=> Table.AddColumn(s, c, each 
                    [ a = List.Combine(Table.SelectRows(GroupedRowsBuffer, (x)=> x[Employee] = c)[Dates]),
                      b = if List.Contains(a, [Date]) then 1 else 0
                    ][b], Int64.Type) )
in
    TransformTable_Dates

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Thank you so much ! 

You're welcome 🙂


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.