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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
FernandoCandido
Frequent Visitor

Compare tables and set a text to values?

I have monthly tables with employees. The IDs just surges and vanish from it, as they are hired and fired. But there is no indication for that.

Can I compare the tables, they are all in one folder, and check wich one is gone and wich one is new? and mark it as new or fired?

I have no idea on how to right it in M language.

Can somebody help me?

 

Basically I get:

 

 

dateID
01/01/2019 157
01/01/2019 199
01/01/2019 201
01/01/2019 202
01/01/2019 205
01/01/2019 333
01/01/2019 349
01/01/2019 357
01/01/2019 358

 

dateID
01/02/2020199
01/02/2020201
01/02/2020202
01/02/2020333
01/02/2020349
01/02/2020350
01/02/2020357
01/02/2020400
01/02/2020401
1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @FernandoCandido, check this:

 

Output

dufoq3_0-1723743489872.png

 

let
    Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NLBSUdJUNTc6VYHQxRS0ssokAaq6gRVlFTLKLGxsbYRE2w2WaM1WXGphZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, ID = _t]),
    Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7BCQAgDEPRXXoWTNOKOIu4/xri1eb6+ITsbfAOdoKwZr6WnfYh4QpZMSIEptiMAYWzYkKU+S6dCw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, ID = _t]),
    MergedQueries = Table.NestedJoin(Table2, {"ID"}, Table1, {"ID"}, "Table1", JoinKind.FullOuter),
    ExpandedTable1 = Table.ExpandTableColumn(MergedQueries, "Table1", {"ID"}, {"Table1.ID"}),
    ReplaceValueID = Table.ReplaceValue(ExpandedTable1,
        each [ID] = null,
        each [#"Table1.ID"],
        (x,y,z)=> if y then z else x,
        {"ID"} ),
    Ad_Status = Table.AddColumn(ReplaceValueID, "Status", each if [date] = null then "Fired" else if [Table1.ID] = null then "New" else "No change", type text),
    RemovedColumns = Table.RemoveColumns(Ad_Status,{"Table1.ID"})
in
    RemovedColumns

 


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

2 REPLIES 2
dufoq3
Super User
Super User

Hi @FernandoCandido, check this:

 

Output

dufoq3_0-1723743489872.png

 

let
    Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NLBSUdJUNTc6VYHQxRS0ssokAaq6gRVlFTLKLGxsbYRE2w2WaM1WXGphZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, ID = _t]),
    Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7BCQAgDEPRXXoWTNOKOIu4/xri1eb6+ITsbfAOdoKwZr6WnfYh4QpZMSIEptiMAYWzYkKU+S6dCw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, ID = _t]),
    MergedQueries = Table.NestedJoin(Table2, {"ID"}, Table1, {"ID"}, "Table1", JoinKind.FullOuter),
    ExpandedTable1 = Table.ExpandTableColumn(MergedQueries, "Table1", {"ID"}, {"Table1.ID"}),
    ReplaceValueID = Table.ReplaceValue(ExpandedTable1,
        each [ID] = null,
        each [#"Table1.ID"],
        (x,y,z)=> if y then z else x,
        {"ID"} ),
    Ad_Status = Table.AddColumn(ReplaceValueID, "Status", each if [date] = null then "Fired" else if [Table1.ID] = null then "New" else "No change", type text),
    RemovedColumns = Table.RemoveColumns(Ad_Status,{"Table1.ID"})
in
    RemovedColumns

 


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

Great!! Thanks. I will try it asap!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.