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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
M_Capps
New Member

Do I need to split a row to graph unique values

Good day,

 

I have the following table that tracks orders and the category(ies) that the items belong in:

 

Order Number Item NumberAgency County Category 1Category 2Category 3Category 4Category 5Category 6Category 7Category 8Category 9Category 10Category 11Category 12
201905378 2-1ACME, Inc. New Hanover    Y     Y  
201905378 2-1ACME, Inc. New Hanover        Y    
201905378 2-2ACME, Inc. New Hanover    Y     Y  
201917154 2JustAnotherPlace Craven    Y        
201917154 3JustAnotherPlace Craven    Y        
202000456 1Knowhere Craven Y     Y     
202000456 1Knowhere Craven Y           
202002107 1Places Pasquotank       Y  Y Y
202002345 1NothingKnew Jones  Y Y   Y    
202002818 1AlwaysOld Pamlico Y  Y        

 

On my visualization, I need this table as-is but also need a Stacked Bar Chart that graphs the data by Agency and Category:

 

M_Capps_0-1691675789802.png

 

When an item has only one category, it graphs correctly. However, when an order has multiple categories for the same item (Order Number 202002345) the graph only picks up the last indicated category. Order Number 202002345 only counts Category 8 and ignores Category 2 and Category 4.

 

The actual table is roughly 25,000 rows so manually splitting isn't feasible.  Is there a way to dynamically code it where I actually can catch multiple categories for the same Order Number and Item.

 

Thanks

 

 

 

 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @M_Capps 

To work effectively with the data in the table, it is necessary to unpivot it.
Don't worry 25K rows is a very small database for a power bi engine.

The steps for unpivot on power query:
1. Select all columns except of categories

Ritaf1983_0-1691723922291.png

 

2. Use the option of "unpivot other columns"

Ritaf1983_1-1691724057306.png

3. close and apply.

4. Create the graph:

Ritaf1983_2-1691724454727.png

 

Link to the sample file 

Please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
Ritaf1983
Super User
Super User

Hi @M_Capps 

To work effectively with the data in the table, it is necessary to unpivot it.
Don't worry 25K rows is a very small database for a power bi engine.

The steps for unpivot on power query:
1. Select all columns except of categories

Ritaf1983_0-1691723922291.png

 

2. Use the option of "unpivot other columns"

Ritaf1983_1-1691724057306.png

3. close and apply.

4. Create the graph:

Ritaf1983_2-1691724454727.png

 

Link to the sample file 

Please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

This did exactly what I was needing it to do. Thanks @Ritaf1983 

Glad to help 🙂

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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