Forum Discussion

mp390988's avatar
mp390988
Icon for Post Partisan rankPost Partisan
1 year ago
Solved

Positioning data labels in Clustered Bar Chart

Hi,

 

I have 2 labels on my bar chart. One under Value which contains my measure Sales. Then another label under Detail which contains my Rank. 

 

 

I want to position the Rank on the left inside the bar and keep my Sales on the right outside the bar. Currently, both labels are aligned next to each other as shown in the photo.

 

 

 

 

Is there a way to position the data label under details?

  • KerKol's avatar
    KerKol
    1 year ago

    Why do you need a company email address?

     

    Another option, is to use a bar chart

     

    create a second measure with a value of (Label = 1) and place this in the x-axis field well,

    under formatting options, 

    select bar overlap

     

    Add value labels to the Label measure and change the default to be the Rank value.

     

    Make the Label measure transparent and change the measure name in the field well to be a space, so that it doesn't show up in legend

     

     

  • Hi mp390988 ,
    We are checking in again to see if the workaround from KerKol was helpful in your scenario.

    Following up on KerKol suggestion I went ahead and tested that workaround and it does achieve your goal of placing:

    • Rank as a data label inside the bar (left-aligned)

    • Sales as a data label outside the bar (right-aligned)

    Final Result:

     

    Steps to Implement it:

    1. Created a dummy measure:

    Label Measure = 1

     

    2. Created a Rank label measure:

    Rank Label = 
    "Rank " & FORMAT(RANKX(ALL('ProductSales'), [Sales Measure], , DESC, DENSE), "00")

     

    3. Create a Sales Measure:

    Sales Measure = SUM('ProductSales'[Sales])

     

    4. Added both measures to the X-axis of a Clustered Bar Chart:

    Sales Measure & Label Measure (used for Rank label)

     

    5. Set Bar Overlap to 100%

     

    6. Assigned data labels:

    Sales Measure --> Position: Outside End; Value: Sales Measure

    Label Measure --> Position: Outside End; Value: Rank Label

     

     

    Output:
    Only one visible bar is shown (Sales), but now:

    -->Rank appears inside left of the bar

    -->Sales remains outside right as expected

     

    This gives the desired two-label effect within Power BI’s native visuals, without using custom visuals like Deneb or Charticulator.

    Thanks again to KerKol  for the creative suggestion - it worked perfectly.

     

    If this helped, please consider marking it as Accepted Solution so other community members can easily find it.

     

6 Replies

  • v-veshwara-msft's avatar
    v-veshwara-msft
    Icon for Community Support rankCommunity Support

    Hi mp390988 ,

    Thanks for posting your query in Microsoft Fabric Community.

    As of now, Power BI doesn’t support independent positioning of multiple data labels on a single bar - meaning you can’t place one label (like Rank) inside the bar on the left and another (like Sales) outside the bar on the right.

     

    That said,

    I tried to replicate your scenario using a workaround in the default clustered bar chart. Here's what I did:

     1. Created a calculated Rank column using RANKX().
     2. Concatenated the Rank and Product Name into a new column.
     3. Used this as the Y-axis to simulate Rank being on the left.
     4. Kept Sales as the X-axis with data labels shown outside right.

     

    Clustered Bar Chart with Rank:

     

    Measures used:

    Product with Rank = FORMAT('ProductSales'[Sales Rank], "00") & " - " & 'ProductSales'[EnglishProductName]

    Sales Rank = RANKX( ALL('ProductSales'), 'ProductSales'[Sales], , DESC, DENSE ) 

     

    While this approach does place the rank to the left, it's technically part of the axis label - not a true data label inside the bar. So, I understand this may not fully meet your intended visual goal.

     

    To achieve precise placement like, Rank inside the bar (left-aligned) and Sales outside (right-aligned)

    You can consider using a custom visual like: Deneb (Vega-Lite based) or Charticulator

    These visuals allow full control over label positioning and layout, which isn’t possible with the default visuals.

     

    Hope this helps. Please reach out for further assistance.
    If this post helps, then please consider to Accept as the solution to help the other members find it more quickly and a kudos would be appreciated.

     

    Thank you.

     

     

     

  • mp390988's avatar
    mp390988
    Icon for Post Partisan rankPost Partisan

    Hi v-veshwara-msft,

     

    Thank you for your response.

     

    This is helpful and I appreciate you saving me time by letting me know that it is not possible to do what I am trying to achieve but I can achieve it using Deneb. The only issue I have is that in order to use Deneb, I need a company email address which I don't have so i'm restricted to using Deneb.

     

    Thank You

    • KerKol's avatar
      KerKol
      Icon for Power Participant rankPower Participant

      Why do you need a company email address?

       

      Another option, is to use a bar chart

       

      create a second measure with a value of (Label = 1) and place this in the x-axis field well,

      under formatting options, 

      select bar overlap

       

      Add value labels to the Label measure and change the default to be the Rank value.

       

      Make the Label measure transparent and change the measure name in the field well to be a space, so that it doesn't show up in legend

       

       

    • v-veshwara-msft's avatar
      v-veshwara-msft
      Icon for Community Support rankCommunity Support

      Hi mp390988 ,
      We are checking in again to see if the workaround from KerKol was helpful in your scenario.

      Following up on KerKol suggestion I went ahead and tested that workaround and it does achieve your goal of placing:

      • Rank as a data label inside the bar (left-aligned)

      • Sales as a data label outside the bar (right-aligned)

      Final Result:

       

      Steps to Implement it:

      1. Created a dummy measure:

      Label Measure = 1

       

      2. Created a Rank label measure:

      Rank Label = 
      "Rank " & FORMAT(RANKX(ALL('ProductSales'), [Sales Measure], , DESC, DENSE), "00")

       

      3. Create a Sales Measure:

      Sales Measure = SUM('ProductSales'[Sales])

       

      4. Added both measures to the X-axis of a Clustered Bar Chart:

      Sales Measure & Label Measure (used for Rank label)

       

      5. Set Bar Overlap to 100%

       

      6. Assigned data labels:

      Sales Measure --> Position: Outside End; Value: Sales Measure

      Label Measure --> Position: Outside End; Value: Rank Label

       

       

      Output:
      Only one visible bar is shown (Sales), but now:

      -->Rank appears inside left of the bar

      -->Sales remains outside right as expected

       

      This gives the desired two-label effect within Power BI’s native visuals, without using custom visuals like Deneb or Charticulator.

      Thanks again to KerKol  for the creative suggestion - it worked perfectly.

       

      If this helped, please consider marking it as Accepted Solution so other community members can easily find it.

       

  • v-veshwara-msft's avatar
    v-veshwara-msft
    Icon for Community Support rankCommunity Support

    Hi mp390988 ,

    Just checking in to see if you query is resolved and if any responses were helpful. If so, kindly consider marking the helpful reply as 'Accepted Solution' to help others with similar queries.

    Otherwise, feel free to reach out for further assistance.

    Thank you.

    Also thanks KerKol for your response and inputs.

  • v-veshwara-msft's avatar
    v-veshwara-msft
    Icon for Community Support rankCommunity Support

    Hi mp390988 ,

    Following up to see if your query has been resolved. If any of the responses helped, please consider marking the relevant reply as the 'Accepted Solution' to assist others with similar questions.

    If you're still facing issues, feel free to reach out.

    Thank you.