Forum Discussion

M_Capps's avatar
M_Capps
Regular Visitor
3 years ago
Solved

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:

 

 

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

 

 

 

 

  • 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

     

    2. Use the option of "unpivot other columns"

    3. close and apply.

    4. Create the graph:

     

    Link to the sample file 

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

3 Replies

  • 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

     

    2. Use the option of "unpivot other columns"

    3. close and apply.

    4. Create the graph:

     

    Link to the sample file 

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