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
Shakaze
Frequent Visitor

Creating a column with 2 others

Hello everyone,

 

I'm working on a project about invoices.

 

I have 2 columns, one is the name the company A sending invoices, and the other the company recuiving the invoice: company B.

A --> B

But i also have the other way around : B --> A


My work is to check if A--> B and B --> A are the same.

 

I have created a column in power Query doing "A_B" and also "B_A"from both column.

What i'm struggling to create is to reunite "A_B" and "B_A" on the same group: "A_B".

 

Shakaze_0-1696495671782.png

 

I could do it for everyline with conditions but if in the future i'm adding new company, i'll have to do it again and again.

 

If anyone has any ideas! Thanks!

 

 

1 ACCEPTED SOLUTION

try creating a custom column, something like

 

= if Text.BeforeDelimiter([YourColumnName], "_") > Text.AfterDelimiter([YourColumnName], "_") then Text.AfterDelimiter([YourColumnName], "_") & "_" & Text.BeforeDelimiter([YourColumnName], "_") else [YourColumnName]

 

Replace [YourColumnName] with the name of your column that has the "A_B" or "B_A" values.

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

3 REPLIES 3
rubayatyasmin
Super User
Super User

@Shakaze 

 

Before you create the "A_B" column, you should make sure that the two companies are sorted alphabetically. This will ensure that the concatenation is consistent.

 

For example in PQ editor,

 

Text.Combine(List.Sort({[CompanyA], [CompanyB]}), "_")

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


@rubayatyasmin Yes it's already sorted alphabetically.

It's logical that i have both "A_B" and "B_A" because in the colum Company i have both A and B.

However what i'm willing to do is to reunite "A_B" and "B_A" to only "A_B".

try creating a custom column, something like

 

= if Text.BeforeDelimiter([YourColumnName], "_") > Text.AfterDelimiter([YourColumnName], "_") then Text.AfterDelimiter([YourColumnName], "_") & "_" & Text.BeforeDelimiter([YourColumnName], "_") else [YourColumnName]

 

Replace [YourColumnName] with the name of your column that has the "A_B" or "B_A" values.

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


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.