Forum Discussion
jijoythomas29
3 years agoNew Member
Dont display table if empty
Hi, I have two tables (A and B) that merge as a single table(C), If table B is empty i dont want the table(C) to be displayed on the sheet. I have tried ISempty function for some reason i fee...
jbwtp
3 years agoMemorable Member
Hi jijoythomas29,
I don't think PQ can "delete" table from Excel if it is empty. On the Excel side, it is a "connection" (like a data pipe from PQ), PQ does not have control over it. Excel does not like if you don't return a table, the query in this case would exit with an error. The closest that I think you can potentially get to what you need is to load a one column, empty table like this:
let
A = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
B = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Filtered Rows" = Table.SelectRows(B, each [Column1] = "A"),
#"Merged Queries" = Table.NestedJoin(#"Filtered Rows", {"Column1"}, #"Filtered Rows", {"Column1"}, "B", JoinKind.LeftOuter),
C = if Table.IsEmpty(#"Filtered Rows") then #table({"Empty"},{}) else Table.ExpandTableColumn(#"Merged Queries", "B", {"Column1"}, {"B.Column1"})
in
C
Cheers,
John
- jijoythomas293 years agoNew Member
Thank you!
Let me test this out!