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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Applicable88
Impactful Individual
Impactful Individual

Combine table with missing records

Hello,

I have a mastercalendar and a facttable. The mastercalendar consist of all dates I need and also icludes a "Productive" indicator to show if a day is a working day or not. In the facttable I got all the records of task which have been done. 
Here are my two example tables:

Mastercalendar:

Date Productive  Month
08.11.2022 1 11
09.11.2022 1 11
10.11.2022 1 11
11.11.2022 1 11
12.11.2022 0 11
13.11.2022 0 11
14.11.2022 1 11
15.11.2022 1 11
16.11.2022 1 11

 

Facttable:

Task Date
Washing 2022-11-08
Cleaning 2022-11-08
Vacuum 2022-11-08
Cleaning 2022-11-09
Washing 2022-11-10
Vacuum 2022-11-10
Washing 2022-11-16

 

All three task needs to be done on every "Productive =1" day: Washing, Cleaning and Vaccum. I need a report where I check if all three things have been done, or which task of a daily task is missing. As you can see on 2022-11-08 all three task have been done, on

2022-11-09 only Cleaning was done, on 2022-11-10 Cleaning is missing and so fourth.... on "ProductiveDay =0" I don't need a check at all. 

When i doing a left join with PQ I can join all dates with mastercalendar but how to check for the missing task? The best would be a Flag which indicates that on a productive day which Task haven't been done, but also don't check for the unproductive days.

 

Thank you very much in advance. 

Best. 

1 ACCEPTED SOLUTION
jbwtp
Memorable Member
Memorable Member

Hi @Applicable88,

 

Please try this:

let 
    Mastercalendar = 
        let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDQMzTUMzIwMlLSUTIEYUOlWB2guCV2cUMDHOKGOMSNkMQNkMSNcYib4DDHFIe4GRbxWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Productive = _t, Month = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Productive", Int64.Type}, {"Month", Int64.Type}})
        in
            #"Changed Type",

    Facttable = 
        let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk8szsjMS1fSUbLQNzTUNzIwMlKK1YlWcs5JTczDJhGWmFxamotPvSWKBMICQwPsBqGJI2kwQ0jEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Task = _t, Date = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Task", type text}, {"Date", type date}})
        in
            #"Changed Type",
    allTask = List.Distinct(Facttable[Task]),

    FirstFilterAllProductive = Table.SelectRows(Mastercalendar, each [Productive] = 1),
    AddTasks = Table.NestedJoin(FirstFilterAllProductive, {"Date"}, Facttable, {"Date"}, "Tasks", JoinKind.LeftOuter),
    #"Expanded Tasks" = Table.ExpandTableColumn(AddTasks, "Tasks", {"Task", "Date"}, {"Task", "Date.1"}),
    #"Grouped Rows" = Table.Group(#"Expanded Tasks", {"Date"}, {{"Completed", each List.ContainsAll(_[Task], allTask), Logical.Type}, {"MissedList", each List.RemoveItems(allTask, _[Task]), type list}, {"MissedText", each Text.Combine(List.RemoveItems(allTask, _[Task]), ", "), type text}})
    

in #"Grouped Rows"

 

Cheers,

John

View solution in original post

1 REPLY 1
jbwtp
Memorable Member
Memorable Member

Hi @Applicable88,

 

Please try this:

let 
    Mastercalendar = 
        let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDQMzTUMzIwMlLSUTIEYUOlWB2guCV2cUMDHOKGOMSNkMQNkMSNcYib4DDHFIe4GRbxWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Productive = _t, Month = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Productive", Int64.Type}, {"Month", Int64.Type}})
        in
            #"Changed Type",

    Facttable = 
        let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk8szsjMS1fSUbLQNzTUNzIwMlKK1YlWcs5JTczDJhGWmFxamotPvSWKBMICQwPsBqGJI2kwQ0jEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Task = _t, Date = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Task", type text}, {"Date", type date}})
        in
            #"Changed Type",
    allTask = List.Distinct(Facttable[Task]),

    FirstFilterAllProductive = Table.SelectRows(Mastercalendar, each [Productive] = 1),
    AddTasks = Table.NestedJoin(FirstFilterAllProductive, {"Date"}, Facttable, {"Date"}, "Tasks", JoinKind.LeftOuter),
    #"Expanded Tasks" = Table.ExpandTableColumn(AddTasks, "Tasks", {"Task", "Date"}, {"Task", "Date.1"}),
    #"Grouped Rows" = Table.Group(#"Expanded Tasks", {"Date"}, {{"Completed", each List.ContainsAll(_[Task], allTask), Logical.Type}, {"MissedList", each List.RemoveItems(allTask, _[Task]), type list}, {"MissedText", each Text.Combine(List.RemoveItems(allTask, _[Task]), ", "), type text}})
    

in #"Grouped Rows"

 

Cheers,

John

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.