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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sscollins
New Member

Grouping by a column then pivoting values to avoid duplicates and null values.

I have a specific use case related to how our data comes into Power BI from our source. Our table dumps all custom fields into one column and their values into another. I need these columns pivoted to have a column for each field, but I also need them to be by their Project ID. For example:

 

Project IDCustomFieldNameCustomFieldValue
Project_ACode12345
Project_ALocationCalifornia
Project_AManagerJohn Doe
Project_BCode12346
Project_BLocationNevada
Project_BManagerJane Doe

 

The project ID repeats, and so what I want for the transformed data to be is:

 

Project IDCodeLocationManager
Project_A12345CaliforniaJohn Doe
Project_B12346NevadaJane Doe

 

Thank you all for the help!

5 REPLIES 5
HotChilli
Super User
Super User

Sample data and show desired result please.

HotChilli
Super User
Super User

can you post the 'advanced editor' code and i'll have a look?

HotChilli
Super User
Super User

You can (using the interface) Group By 'Project Id'.  Select only one aggregation : All rows.  Call the column "all".

Then add a custom column:

Table.Pivot([all], {"Code","Location","Manager"} ,"CustomFieldName", "CustomFieldValue")

and you can expand from the column header to return the appropriate fields

Hello, I am having a similar issue as below - i merge by person id and add custom column but when i expand from column header it undoes the grouped by. Before there were 3 of the same id and the new line converts the grouped by to 2 lines the same id. I'm guessing its something to do with null values and some values being empty. Not sure how to fix.

Hi, thanks for the help. I attempted this and this was my experience: Grouping helped in that there was only one row per project ID, and the custom column and formula worked and produced another column. But upon splitting out the three fields I want, the grouped column "all" becomes ungrouped, all the lines come back and I am left with the same null fields in most of the expanded column. I tested how this affected my dashboard and the custom fields are still not connecting with eachother. Any thoughts?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.