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
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

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

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

Glad to help 🙂

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.