Forum Discussion
Compare difference between two tables.
- 5 years ago
The proper way would be to create a data model with Name and Medium dimension tables that would then control the two fact tables. But a simpler option would be to take advantage of the merging functions in Power Query that allow you to link tables by more than one column.
Pre Contents table:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcirKTMxT0lFyzU3MzAHSnnlKsToIYV+IqH9pCYpwsG8wptqAjPy8VKhwLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Medium = _t, Opted = _t]) in SourceContents table:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcirKTMxT0lFyzU3MzAHS/qUlSrE6CHFf7MLBvsFA0jMPRTAgIz8vFaY4FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Medium = _t, Opted = _t]), #"Merged Queries" = Table.NestedJoin(Source, {"Name", "Medium"}, #"Pre Consents", {"Name", "Medium"}, "Pre Consents", JoinKind.LeftOuter), #"Expanded Pre Consents" = Table.ExpandTableColumn(#"Merged Queries", "Pre Consents", {"Opted"}, {"Opted.1"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded Pre Consents",{{"Opted.1", "Pre"}}), #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Concern", each if [Pre]="In" and [Opted] = "Out" then 1 else 0), #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Concern] = 1)) in #"Filtered Rows"
The proper way would be to create a data model with Name and Medium dimension tables that would then control the two fact tables. But a simpler option would be to take advantage of the merging functions in Power Query that allow you to link tables by more than one column.
Pre Contents table:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcirKTMxT0lFyzU3MzAHSnnlKsToIYV+IqH9pCYpwsG8wptqAjPy8VKhwLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Medium = _t, Opted = _t])
in
Source
Contents table:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcirKTMxT0lFyzU3MzAHS/qUlSrE6CHFf7MLBvsFA0jMPRTAgIz8vFaY4FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Medium = _t, Opted = _t]),
#"Merged Queries" = Table.NestedJoin(Source, {"Name", "Medium"}, #"Pre Consents", {"Name", "Medium"}, "Pre Consents", JoinKind.LeftOuter),
#"Expanded Pre Consents" = Table.ExpandTableColumn(#"Merged Queries", "Pre Consents", {"Opted"}, {"Opted.1"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Pre Consents",{{"Opted.1", "Pre"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Concern", each if [Pre]="In" and [Opted] = "Out" then 1 else 0),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Concern] = 1))
in
#"Filtered Rows"Morning, Many thanks for the above, if my queries is built from XML can the above be added ? Sorry for stupid question but never attempted this before.
Cheers