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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Shan_Drex12
Helper I
Helper I

If Statement with Custom column (yes or no)

Hi All,

 

I have two tables here, That I want to merge together 

Table1

NumberSector
2378Vision
8908Clothing
2311Vision

 

, Table2

EntryNumberSector
2378Vision
4568Clothing
2311Vision

 

If match the criteria from (Table1) to Table2 then make a custom column that return the status is "Yes" if it does not match then return the status is "No". 

 

Final Table:

NumberSectorMatch Column
2378VisionYES
8908ClothingNO
2311VisionYES
4 REPLIES 4
Jimmy801
Community Champion
Community Champion

Hello @Shan_Drex12 

 

didn't get exactly your requirement. Please make a table where you define what your final output should look like

 

BR

 

Jimmy

Hi @Jimmy801 

I added the final results in the orginal post. Thank you!

Hello @Shan_Drex12 

 

you can use Table.MatchAnyRows to do that. However I had to rename the columns before feeding this function. Here the code that contains both of your tables and the function i mentioned. Check it out

let
    Table1 = let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2t1DSUQrLLM7Mz1OK1YlWsrA0AIk45+SXZGTmpYPFjIwNDZFUxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Number = _t, Sector = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}, {"Sector", type text}})
        in
            #"Changed Type",
    Table2 = let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2t1DSUQrLLM7Mz1OK1YlWMjE1A4k45+SXZGTmpYPFjIwNDZFUxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EntryNumber = _t, Sector = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"EntryNumber", Int64.Type}, {"Sector", type text}})
        in
            #"Changed Type",
    CheckTable2Matches = Table.AddColumn
    (
        Table1,
        "is entry in table 2",
        (add)=> Table.MatchesAnyRows(Table.RenameColumns(Table2, {{"EntryNumber", "Number"}}), each _ = add ),
        type logical
    )
in
    CheckTable2Matches

This is the output

Jimmy801_0-1616830874320.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Thanks @Jimmy801 quick question. Would this work if its two data sets. Would I have to merge the columns based on a full outer join on "Number" to keep everything and then do this custom column formula?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors