Forum Discussion

FredNo's avatar
FredNo
Frequent Visitor
3 years ago

Stacked column chart with multiple columns groupe into categories

Hi, I am having some kind of difficulties dealing with grouping columns under custom categories. I have the following dataset as an example:

I have 9 temperature sensors that can give 3 values: Low, Medium, High.

 

The dataset also has around 12 other columns for other values.

 

idsensor1sensor2sensor3sensor4sensor5
1LowLowMediumHighHigh
2MediumMediumLowMedium

High

3MediumMediumMediumHigh

High

 

I am trying to parse my data into powerbi with a stacked column chart. However, I want to regroup the sensors under 2 categories. Category A will include sensors 1 2 and 3 and Category B will include sensors 4 and 5.

 

The chart I would like to have as a result is something like that.

 

 

I am counting the instances when there is a "low medium high" listed for each sensor.

 

I have tried to unpivot method into another table but that second table ended up having as many rows as my reference one. I have read a little bit about disconnected tables but did not really figure out how and if that can solve my problem with a table that would look like that as a reference table for grouping:

 

category

subcategory

CategoryA

sensor1

CategoryA

sensor2

CategoryA

sensor3

CategoryB

sensor4

CategoryB

sensor5

 

 

Thank you

 

 

3 Replies

    • FredNo's avatar
      FredNo
      Frequent Visitor

      Unpivoting the main table is not really an option for me because I can only take one row for my calculations. And by unpivoting i am duplicating the rows for the same entry id. I cannot take multiple row for the same entry since I must take the most recent one. I forgot to add in my example a column associated to the employee who is adding the row. I only use the latest entry per employee labeled as the "latest entry" and not the previous ones

  • FredNo's avatar
    FredNo
    Frequent Visitor

    So what I ended up doing as a "spaghetti solution" is that I created a table referencing my main table and then delete all rows except the necessary ones and my id column. This gave something like that:

    idAttributeValueCategory
    1Sensor1LowGroupA
    1Sensor2LowGroupA
    1Sensor3MediumGroupA
    1Sensor4HighGroupB
    1Sensor5HighGroupB
    2Sensor1MediumGroupA
    2Sensor2MediumGroupA
    2Sensor3LowGroupA
    2Sensor4MediumGroupB
    2Sensor5HighGroupB

     

    In my opinion this is not the ideal solution since the new table has as much rows as the reference one but this works for my needs.