Forum Discussion

eneri's avatar
eneri
Icon for Helper I rankHelper I
1 year ago
Solved

Adjusting X-Axis Max with Visual Calculation for Stacked Bar Chart

I've recently learned from a youtube video that it is possible to use visual calculation to increase the range of an axis dynamically to e.g. have 1.1 x the value of the longest. Now I've tried this ...
  • eneri's avatar
    eneri
    1 year ago

    Thanks for the detailed reply and all the suggestions, unfortunately:

    • When used as visual calculations, they give the same result as above: selecting the total value * 1.1 not the value of the longest bar. 
    • When using ALLSELECTED() in a "normal" measure I get an error message: 

    What did work is this measure (not visual calculation) - (cyan rectangle in screenshot below)

    max_by_type =1.1 * MAXX([dim_column],[measure])

     

    Using the same syntax as visual calculation

    vc = 1.1* MAXX(ROWS,[measure]

    is not working (red rectangle in screenshot below)

     

  • v-echaithra's avatar
    1 year ago

    Hi eneri ,

    Your DAX measure using MAXX(VALUES(dim_column), [measure]) works correctly because it calculates the maximum total per bar via row context, whereas the visual calculation MAXX(ROWS, [measure]) fails for axis scaling since it evaluates across individual segments rather than entire rows, leading to incorrect results like the total sum instead of the maximum row.

    Use this DAX measure to dynamically scale your axis based on the longest individual bar:

    max_by_type =1.1 * MAXX([dim_column],[measure])

    Replace dim_column with the dimension that defines each bar (example: Category, Type, etc.).

    Use this measure (max_by_type) as a reference to x axis, set the x-axis maximum manually or use it in layout logic.
    Please provide sampple data, so we can reproduce your requirement.

    Hope this helps.
    Best Regards,
    Chaithra E.