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
DianaT
Helper I
Helper I

How to reorganise text data into two columns

Hi all,

 

I am new to Power bi and I am at a complete loss

 

I have the following dataset. What I try to do is to eliminate blank and to force the two agent names on each row into Plan manager 1 and Plan manager 2. For example, PM1 should be Simone and PM2 should be Claire on the first row:

 

Agent 1                 Agent 2                    Agent 3                       Agent 4                    PM 1                     PM 2

Simone                 Claire

Simone                                                 Jane

                                                             Jane                              Peter

                             Claire                       Jane

Simone                                                                                       Peter

 

Any expert help will be greatly appreicated here. Thank you very much.

 

Diana

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

Hi, @DianaT 

Based on your description, i created data to reproduce your scenario.

 

You can click ‘Edit Query’, go to Query Editor, select ‘Agent1’ and ‘Agent2’, choose ‘Transform’ pane, click ‘Merge Columns’.

 

c2.png

In ‘Merge Columns’, the configuration is as follows.

c3.png

You may repeat the above steps to merge the result with ‘Agent3’ and ‘Agent4’.

xc.png

Then you can go to ‘Transform’ pane, click ‘Split Columns’, choose ‘By Lowercase to Uppercase’ and rename the correspond columns.

c4.png

Result:

c5.png

 

If I misunderstand the your thoughts, please show us your expected output. I am glad to solve the problem for you.

 

 

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

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @DianaT 

Based on your description, i created data to reproduce your scenario.

 

You can click ‘Edit Query’, go to Query Editor, select ‘Agent1’ and ‘Agent2’, choose ‘Transform’ pane, click ‘Merge Columns’.

 

c2.png

In ‘Merge Columns’, the configuration is as follows.

c3.png

You may repeat the above steps to merge the result with ‘Agent3’ and ‘Agent4’.

xc.png

Then you can go to ‘Transform’ pane, click ‘Split Columns’, choose ‘By Lowercase to Uppercase’ and rename the correspond columns.

c4.png

Result:

c5.png

 

If I misunderstand the your thoughts, please show us your expected output. I am glad to solve the problem for you.

 

 

Best Regards,

Allan

 

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

 

Thank you so much! I was so stuck into thinking this had to be solved through DAX. This is great.

JarroVGIT
Resident Rockstar
Resident Rockstar

Alright, another fun one! The solution I've created was one with calculated columns. I started with this table:

image.png

Now first, we are going to concatenate all names in all columns and filter out the empty values. We create a new column with the following DAX and result:

Concatenated = 
VAR name1 = IF('Table'[Name1] = "", "abc1", 'Table'[Name1])
VAR name2 = IF('Table'[Name2] = "", "abc1", 'Table'[Name2])
VAR name3 = IF('Table'[Name3] = "", "abc1", 'Table'[Name3])
VAR name4 = IF('Table'[Name4] = "", "abc1", 'Table'[Name4])
VAR concatenadText = name1&"--"&name2&"--"&name3&"--"&name4
VAR firstFiltered = SUBSTITUTE(concatenadText, "--abc1", "")
VAR twoNames = SUBSTITUTE(firstFiltered, "abc1--", "")
RETURN
twoNames

This could've been cleaner but this way you can see every step what I am trying to do. Resulting in the following table:

Note i've used double dashes, as Names might contain single dashesNote i've used double dashes, as Names might contain single dashes

Now, the following dax created PM1 and PM2 column:

PM1 = 
VAR ind = FIND("--", 'Table'[Concatenated], 1)
RETURN
LEFT('Table'[Concatenated], ind-1)
PM2 = 
VAR ind = FIND("--", 'Table'[Concatenated], 1)
RETURN
RIGHT('Table'[Concatenated], LEN('Table'[Concatenated])-ind-1)

The end result looks like this:

image.png

Well, that's it! That was a fun question to answer 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you so much. Don't think I would ever come up with this. Speaking of steep learning curve. I'll test this on my data and see how this DAX works. Cheers!

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.