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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Move duplicates from one column to another column

Hi,

 

My data consists of:

- A company name (Column1)

- A company code (Column2)

- An IP-address (Column 3)

 

Some companies share a data center and therefore have 1 outgoing IP-address.

What I want is to remove the duplicate rows (based on IP-address)  from the companies they belong to and move them to a another company (that I need to create as some sort of 'other' category).

 

I tried some stuff in the power query editor but got "Expressions.Error" that the name (I tried it with an IF and with a CALCULATE statement) was not recognized. Am I using the wrong language in the wrong editor?

 

Thx in advance!

1 ACCEPTED SOLUTION

Hey,

 

this will do what you are looking for in the QueryEditor

 

  1. Group your table
    From the Transfor menu select "Group by"
    image.png
  2. Expand the table in the "dummy" column
    image.png

    image.png

    Finally you can create a custom column, that assigns the "Z-company" if the value of the Count column is gt 1 otherwise return the value from the Company code column, like so:
  3. Create custom column
    From the menu "Add column" choose "Custom column"
    image.png





 

Hopefully this is what you're looking for, here is a little screenshot of my final table using your sample data:

image.png

 

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

6 REPLIES 6
TomMartens
Super User
Super User

Hey,

 

yes the wrong language in the wrong editor IF and CALCULATE are DAX functions Smiley Wink

if (really, all lowercase 🙂 ) can be used in the QueryEditor, meaning the language is M

 

Maybe you can provide en Excel file with some sample data that also contains a column with the result you expect, upload the sample file to onedrive or dropbox and share the link.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi,

 

So this editor is only for M? Than where can I use DAX funxctions?

Below you can find an example of the data I use.

As you can see every company has a unique company code but an IP-adress can be shared between companies (for example if they have a contract with the same data center). 

 

What I want is to remove the rows that have an a duplicate IP-address and move them all to a newly created 'fake' company (for example Z with company code NL-999).

 

Company nameCompany codeIP-address
aNL-12356.128.128.5
aNL-12356.128.128.6
aNL-12356.128.128.7
aNL-12356.128.128.8
bNL-12456.128.128.5
bNL-12423.100.100.1
cNL-12599.88.253.253
dNL-12656.128.128.5
dNL-126100.73.99.100
eNL-12799.88.253.253
eNL-12756.128.128.5
eNL-127100.73.99.101

Hey,

 

this will do what you are looking for in the QueryEditor

 

  1. Group your table
    From the Transfor menu select "Group by"
    image.png
  2. Expand the table in the "dummy" column
    image.png

    image.png

    Finally you can create a custom column, that assigns the "Z-company" if the value of the Count column is gt 1 otherwise return the value from the Company code column, like so:
  3. Create custom column
    From the menu "Add column" choose "Custom column"
    image.png





 

Hopefully this is what you're looking for, here is a little screenshot of my final table using your sample data:

image.png

 

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Many thanks Tom!

Hey,

 

maybe this gets you started to write some DAX code:

https://docs.microsoft.com/en-us/power-bi/desktop-quickstart-learn-dax-basics

 

If I understand you correctly you want a column that uses the same "company code" for all the ip's that are used by more than one company, and "reuses" the original company code if the ip address is not shared?

 

Regards,

Tom  



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi,

 

The IP-address in this table is the key to connect to the logfile in which usage of sources is monitored.

Since the IP-address in the logfile could have multiple occurences, we have to make sure that the IP-address in this table is unique (otherwise you can't create a relationship between this table and the logfile). Another reason if of course that we can't pinpoint specific usage to a certain company if the IP-address is shared.

 

So the rows with a unique IP-address should stay where they are.

And indeed I want that all duplicate IP-addresses have the same company name and code (multiple rows since there's 1 IP-address per row) and are deduplicated (since I want only unique IP-addresses in the table).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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