Forum Discussion

the_kent's avatar
the_kent
New Member
5 years ago
Solved

Creating a Stacked Bar Chart with data from Multiple Columns AND a column with Multiple Values

Hi all,   Extensive Excel user (sans VBA) but relatively new to PowerBI here. I'm trying to transform some oldish table summary reports to Live dashboards in PowerBI hence in a quandry in translat...
  • BA_Pete's avatar
    BA_Pete
    5 years ago

    the_kent ,

     

    No worries. I'm guessing your score values went through the roof when you tried to sum them as you've not reaggregated the data into unique row sets.

    This is why in my steps I had the Group By step at the end. This reaggregates on an average basis (not sum!) the duplicated rows that were created by the unpivot steps. Average works here as we know we are only grouping duplicated rows, so the average of them will just be the original value that was duplicated.

    Unpivoting once isn't a problem as the data is recategorised correctly into a normalised structure. It's when we unpivot twice (due to two lots of different dimensions needing to be normalised) that we then get erroneous duplications. We are essentially creating a crossjoin on the second unpivot against each of the previously normalised values from the first unpivot.

     

    TL;DR - You have to do the Group By step to reaggregate your scores correctly.

     

    *EDIT* I ws a bit confused reading where you say that I'd included [score] in my unpivot columns so I rechecked it and it appears this way because Power Query has actually done a code switch. I used the Unpivot function from the GUI which you would expect to produce the function Table.UnpivotColumns(theColumnsYouHadSelected). However, it's actually turned it on its head an created the M code as Table.UnpivotOtherColumns(theColumnsYouDidn'tHaveSelected). A bit confusing, to be sure, but correct in terms of output.

     

    Pete