Forum Discussion

littlemojopuppy's avatar
littlemojopuppy
Icon for Community Champion rankCommunity Champion
9 years ago
Solved

Stacked Bar Chart with Groupings

Hi!  I'm hoping this is a really easy question that comes down to operator error due to relative unfamiliarity with PowerBI.  Any help would certainly be appreciated.  I have a bar chart that's showing the customer count by region.

I have some performance guardrails that are included as measures...for example a customer was less than minimum, less than target or over target.  I want to have each of these three shown as groups on this chart.

 

What I've done: I've created measures to calculate the customer's performance metric and then a second measure for grouping based on the first metric.  I try to add that grouping measure to the Legend and nothing happens.  Could anyone please help?

  • Good morning!

     

    So if the thing creating the problem was using Direct Query mode I changed the data connection to Import instead.  There was no reason it had to be Direct Query other than I'm a novice.  After changing the data connection I went back to creating a column for the grouping.  And it worked!

    Thank you for your help!

6 Replies

  • littlemojopuppy's avatar
    littlemojopuppy
    Icon for Community Champion rankCommunity Champion

    One thing I want to add...if I add a field defined in the data (not a calculated measure) such as sales person or area, it works.  It doesn't seem to like the calculated measure being what it's supposed to group by.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi littlemojopuppy,

       

      For your requirement, you can use calculate column to calculate the target, then drag it to axis field.

       

      For example:

       

      TargetColumn =
      var target= AVERAGEX(ALL(Sheet2),[Amount])*0.75
      Return
      if([Amount]>target,"Over target","Less than target")

       

       

      In addition, you can drag your original axis column to legend field to show the detail info.

       

      Regards,

      Xiaoxin Sheng

      • littlemojopuppy's avatar
        littlemojopuppy
        Icon for Community Champion rankCommunity Champion

        Apologies if this reply is duplicated...my original response doesn't seem to be here.

         

        I set up two measures for the minimum and target (but I like how you're calculating the 75% of average interactively!)  The formula to determine which grouping a record should be in is as follows: Net TGP Per Case Grouping = IF([Net TGP Per Case]<[Net TGP Per Case Minimum],"Below Minimum",IF(AND([Net TGP Per Case]>=[Net TGP Per Case Minimum],[Net TGP Per Case]<[Net TGP Per Case Target]),"Below Target","Above Target")).

         

        The requirement is to have geography shown on the axis since the rest of the dashboard will be based on geography.  What I'm looking for is what's shown as a solid green bar to be broken into three segments, one for each of the groupings below min, below target and above target.  Here's an Excel mock-up of what I'm trying to get to.

        Thank you for any help you might be able to provide!