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
inglexjc
Helper IV
Helper IV

Separate names in columns based on Role in separate column.

Current table V_TRAILS_CASE_CATEGORY shows:

 

CAS_IDD_STF_PERS_NMEROLE
1234One, TechPrimary
1235Two, TechSecondary
1236Three, TechPrimary
1237Two, TechSecondary

 

I would like it to show as:

CAS_IDPrimarySecondary
1234One, Tech 
1235 Two, Tech
1236Three, Tech 
1237 Two, Tech
1 ACCEPTED SOLUTION
marcelsmaglhaes
Super User
Super User

Hey @inglexjc 

 

In Power Query you should select the ROLE column in your query, and then, in Transform menu, choose the Pivot Column buton and copy the configuration of the image bellow.

marcelsmaglhaes_0-1701211086392.png

After you fill the option, click in OK. You will see the result you are looking for.

marcelsmaglhaes_1-1701211133991.png

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!
Imagem de fundo



View solution in original post

4 REPLIES 4
marcelsmaglhaes
Super User
Super User

Hey @inglexjc 

 

In Power Query you should select the ROLE column in your query, and then, in Transform menu, choose the Pivot Column buton and copy the configuration of the image bellow.

marcelsmaglhaes_0-1701211086392.png

After you fill the option, click in OK. You will see the result you are looking for.

marcelsmaglhaes_1-1701211133991.png

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!
Imagem de fundo



ExcelMonke
Resolver I
Resolver I

You could try the following, by creating a new table. Go to modeling, create table with the following DAX:

 

 

Union(
SELECTCOLUMNS(Filter('Table','Table'[D_STF_PERS_NME]="One, Tech"),"CAS_ID",'Table'[CAS_ID],"Primary","One, Tech","Secondary",""), 
//Looks for all D_STF_PERS_NME with "One, Tech" and creates a column named "Primary" and for each matching ID will return a value of "One, Tech", and blank in the "Secondary" column.

SELECTCOLUMNS(Filter('Table','Table'[D_STF_PERS_NME]="Three, Tech"),"CAS_ID",'Table'[CAS_ID],"Primary","Three, Tech","Secondary",""), //Looks for all D_STF_PERS_NME with "Three, Tech" and creates a column named "Primary" and for each matching ID will return a value of "Three, Tech", and blank in the "Secondary" column.

SELECTCOLUMNS(Filter('Table','Table'[D_STF_PERS_NME]="Two, Tech"),"CAS_ID",'Table'[CAS_ID],"Primary","","Secondary","Two, Tech")//Looks for all D_STF_PERS_NME with "Two, Tech" and creates a column named "Primary" and for each matching ID will return a value of Blank, and "Two, Tech" in the "Secondary" column.

)

 

 

 

Hope this helps!

I changed the names of the D_STF_PERS_NME to be One, Tech; Two, Tech; Three, Tech to protect PII.  what if there are REAL names that are different listed under D_STF_PERS_NME?

Hmm... you could try switching the filter clause to look at the role column and the selectcolumns clauses to return the D_STF_PERS_NME rather than a static value, although I have not tried this out myself yet. 

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.