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
Anonymous
Not applicable

check data while importing

Good day,

I am new bee and trying to create a logic so that before importing the new data in PowerBi, it checks the 2 fields (IPAddress+ServerName) from the new file into existing file.

For e.g. If data (2 fields are not matched or no duplicates) doent exist, it would continue to append that record from new file to old file and also update status column field to "NEW" to mark this record as a new record.

If data (2 fields are matched and duplicate record exist) exist than it no record added, just  update status column field to "ACTIVE" for that row.

 

What is the best approach to manage that ? Just looking for the pointers in the right directions. Thank you

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table1:

a1.png

Table2:

a2.png

Table3:

a3.png

 

You may create a function with the following m codes in 'Advanced Editor'.

let
    Merge1 = (t1 as table,t2 as table) =>
let
    Source1 = Table.NestedJoin(t1, {"IPAddress", "ServerName"}, t2, {"IPAddress", "ServerName"}, "T", JoinKind.LeftOuter),
    Source2 = Table.NestedJoin(t2, {"IPAddress", "ServerName"}, t1, {"IPAddress", "ServerName"}, "T", JoinKind.LeftAnti),
    Source3 = Table.NestedJoin(t1, {"IPAddress", "ServerName"}, t2, {"IPAddress", "ServerName"}, "T", JoinKind.Inner),
    Result = Table.RemoveColumns( Table.Combine({Source1,Source2}),"T"),
    Res = Table.AddColumn(
        Result,
        "Status",
        each if 
        Table.RowCount(
            Table.SelectRows(
                Source3,
                (x)=>x[IPAddress]=[IPAddress] and x[ServerName]=[ServerName]
            )
        )>0
        then "Active"
        else "New"
    )
in
    Res
in
    Merge1

 

a4.png

 

Append 'Table1' and 'Table2':

a7.png

 

Append 'Table2' and 'Table3':

a8.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table1:

a1.png

Table2:

a2.png

Table3:

a3.png

 

You may create a function with the following m codes in 'Advanced Editor'.

let
    Merge1 = (t1 as table,t2 as table) =>
let
    Source1 = Table.NestedJoin(t1, {"IPAddress", "ServerName"}, t2, {"IPAddress", "ServerName"}, "T", JoinKind.LeftOuter),
    Source2 = Table.NestedJoin(t2, {"IPAddress", "ServerName"}, t1, {"IPAddress", "ServerName"}, "T", JoinKind.LeftAnti),
    Source3 = Table.NestedJoin(t1, {"IPAddress", "ServerName"}, t2, {"IPAddress", "ServerName"}, "T", JoinKind.Inner),
    Result = Table.RemoveColumns( Table.Combine({Source1,Source2}),"T"),
    Res = Table.AddColumn(
        Result,
        "Status",
        each if 
        Table.RowCount(
            Table.SelectRows(
                Source3,
                (x)=>x[IPAddress]=[IPAddress] and x[ServerName]=[ServerName]
            )
        )>0
        then "Active"
        else "New"
    )
in
    Res
in
    Merge1

 

a4.png

 

Append 'Table1' and 'Table2':

a7.png

 

Append 'Table2' and 'Table3':

a8.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

That is standard functionality in Power Query.  Describe your rules (as you did above) and then implement them in Power Query.   Ideally your files sit in the same folder structure so you can use the Folder connector rather than hard coding individual files as sources.

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