Forum Discussion

RaMiRo87's avatar
RaMiRo87
Frequent Visitor
2 years ago
Solved

Dynamic y-axis bar chart - prevent data labels from overlapping

Hi folks,

 

I have a problem with overlapping data labels in my bar charts and need urgently help! 

My problem is certainly of a rather simple nature, but I have not yet been able to find a 100% suitable topic in the community.

 

The data labels are no longer displayed above the respective column for the maximum values, but are either written in the column or half and half. Both variants are known to be illegible.

 

One of my bar charts contains the sales regions [Legal Entity] on the X-axis and the incoming orders [Incoming Orders] on the Y-axis. The bar charts are filtered by a period slicer (MTD, YTD etc.). The column [Legal Entity] and [Incoming Orders] both originate from the fact table 'fcontrolling'.

 

Now I would like that when I select different periods via my slicer, the scales of the column charts are dynamically adjusted to the highest value within this filtered period and there is always a little whitespace above and below the columns so that there is enough space for the data labels.

 

Many thanks for your help in advance!

 

Best regards
Ramirez

  • RaMiRo87 , Ideally it should adjust , if you are using field parameters to switch measures

     

    else create min and max like

     

    min = minx(Values([Legal Enity), [Your measure] )*.9

     

    max = maxx(Values([Legal Enity), [Your measure] )* 1.1

     

     

    and use them in Y-axis Min/Max values  

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, RaMiRo87 

    You can define a measure of the maximum value of the Y-axis, which depends on the field or measure used by your Y-axis. I created a sample as follows:

    At this point, 900 is inside the column, and here are the steps to adjust it:

    Visual>>Y-axis>>Turn off Logarithmic scale

    Create a measure based on the field or measure you use on the Y-axis. The purpose of the entire maximum value is to allow the maximum value to be displayed on the Y axis higher than your actual maximum value.

    Max y-axis = [Sum of sales]*1.1 

    Click Maximum fx

    In your case, your DAX expression should look something like this:

    MaxValue =
    CALCULATE (
        MAX ( 'fcontrolling'[Incoming Orders] ),
        ALLSELECTED ( 'fcontrolling' )
    ) * 1.1
    

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, RaMiRo87 

    You can define a measure of the maximum value of the Y-axis, which depends on the field or measure used by your Y-axis. I created a sample as follows:

    At this point, 900 is inside the column, and here are the steps to adjust it:

    Visual>>Y-axis>>Turn off Logarithmic scale

    Create a measure based on the field or measure you use on the Y-axis. The purpose of the entire maximum value is to allow the maximum value to be displayed on the Y axis higher than your actual maximum value.

    Max y-axis = [Sum of sales]*1.1 

    Click Maximum fx

    In your case, your DAX expression should look something like this:

    MaxValue =
    CALCULATE (
        MAX ( 'fcontrolling'[Incoming Orders] ),
        ALLSELECTED ( 'fcontrolling' )
    ) * 1.1
    

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • RaMiRo87's avatar
      RaMiRo87
      Frequent Visitor

      Hi Anonymous,

       

      thank you very very much for the detailled description! 

       

      Especially your measure was nice to compare it to my current solution. 🙂

       

      Thanks a lot!

  • RaMiRo87 , Ideally it should adjust , if you are using field parameters to switch measures

     

    else create min and max like

     

    min = minx(Values([Legal Enity), [Your measure] )*.9

     

    max = maxx(Values([Legal Enity), [Your measure] )* 1.1

     

     

    and use them in Y-axis Min/Max values  

    • RaMiRo87's avatar
      RaMiRo87
      Frequent Visitor

      Hi amitchandak,

       

      shoul do the trick. Thank you very much for your quick response! 🙂