Forum Discussion

Danbert's avatar
Danbert
Frequent Visitor
6 years ago
Solved

Stacked Bar Chart

Hi

 

In the below visual, my source data is as it appears in the upper table, but I need to find a way to manipulate the data so it appears like it does in the lower table.

 

I need to create a stacked bar chart in power bi as in the example below, and I can do that by using the upper table as a source, but I can not find a way to sort it so that the most billable time is sorted first, then the non-billable, then the absence, but I can only get it to sort by total time.  With the lower table as a source this is not a problem.  

 

Can anyone enlighten me as to how I can either transform the upper table to the lower one, or how I can get my desired result from the structure in the upper table?

 

 

  • Nathaniel_C's avatar
    Nathaniel_C
    6 years ago

    Hi Danbert ,

    Dummied up a table for you, you will end up with a table like this by selecting the Type Column and Selecting Pivot on the Transform tab. Use Time as the values.
    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
    Nathaniel

     







     The picture below shows both the selection for Pivot Column and the resulting table.

     

     

8 Replies

  • Nathaniel_C's avatar
    Nathaniel_C
    Community Champion

    Hi Danbert ,
    Would you copy and paste your first table right into the message so that we can copy and paste it into Power Query? Cannot do that  with pictures.
    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
    Nathaniel

    • Nathaniel_C's avatar
      Nathaniel_C
      Community Champion

      Hi Danbert ,

      Dummied up a table for you, you will end up with a table like this by selecting the Type Column and Selecting Pivot on the Transform tab. Use Time as the values.
      Let me know if you have any questions.

      If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
      Nathaniel

       







       The picture below shows both the selection for Pivot Column and the resulting table.

       

       

    • Danbert's avatar
      Danbert
      Frequent Visitor

      Hi Nathaniel_C , of course, sorry about that.  Please see below:

       

      UserTimerLogDurationJobTypeJobTypeID
      John Smith50Billable1
      Dave Brown100Non-Billable2
      Mary Jones15Billable1
      John Smith150Billable1
      John Smith200Absent3
      Sally Wood27Non-Billable2
      Frank Walston35Billable1
      Sally Wood84Absent3
      Frank Walston94Non-Billable2
      • Nathaniel_C's avatar
        Nathaniel_C
        Community Champion

        Hi Danbert beat you to it with a dummy table. Let me know if this makes sense.😁