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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.