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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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