Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
nleuck_101
Responsive Resident
Responsive Resident

Max y-axis based on field parameter selected

Hello All,

 

I could use some help getting the max y-axis from the selected field parameter slicer. I don't like that the y-axis is showing 800 when the total is over 800. I would pefer it be 1,000 in this scenario. 

nleuck_101_0-1759759806749.png

 

When I change my field parameter to my next slicer it looks a little better but it's still over the number shown in the y-axis.

nleuck_101_1-1759759987249.png


I basically need a dynamic y-axis that gets the max value based on the field parameter selected. Any help would be greatly appreciated.

 

4 REPLIES 4
v-prasare
Community Support
Community Support

You can handle this by using SELECTEDVALUE() on your field parameter table and conditionally computing the max based on which measure is active.

Step 1. Create your field parameter (which you already have):

Measure Parameter =

{ ("Name1", NAMEOF([Measure1]), 0),

    ("Name2", NAMEOF([Measure2]), 1),

    ("Name3", NAMEOF([Measure3]), 2) }

Step 2. Create a new measure for Dynamic Y-Axis Max:

Dynamic Y-Axis Max =

VAR SelectedMeasure = SELECTEDVALUE('Measure Parameter'[Name])

VAR MaxValue = SWITCH(  SelectedMeasure, "Name1",

MAXX(ALLSELECTED('YourMainDataTable'), [Measure1]), "Name2",

MAXX(ALLSELECTED('YourMainDataTable'), [Measure2]), "Name3",

            MAXX(ALLSELECTED('YourMainDataTable'), [Measure3]) )

VAR PaddedValue = MaxValue * 1.15

VAR RoundedValue =

    SWITCH(

        TRUE(),

        MaxValue = 0, 10,

        PaddedValue > 500, ROUNDUP(PaddedValue, -2),

        PaddedValue > 100, CEILING(PaddedValue, 50),

        PaddedValue > 10, CEILING(PaddedValue, 10),

        CEILING(PaddedValue, 5) )

RETURN RoundedValue

 

Use this measure to drive the Y-axis in your chart

Hi @nleuck_101 ,

As I am also a member of the CST team, I wanted to follow up regarding the issue.

I hope the information provided helps resolve your issue. If you have any further questions or need additional assistance, please feel free to contact us. We are here to help.

 

Best Regards, 
Community Support Team

DataNinja777
Super User
Super User

Hi @nleuck_101 ,

 

You can absolutely create a dynamic Y-axis that adjusts to your field parameter. The solution is to write a single DAX measure that calculates an appropriate maximum value based on the data visible in the chart. This measure will then be used to control the Y-axis range in your chart's formatting options.

 

First, you'll need to create a new measure in Power BI. This DAX code finds the highest value among the currently visible bars, adds a 15% buffer for headroom, and then intelligently rounds that value up to a clean, readable number. For instance, a max value of 860 will result in an axis of 1000, and a max value of 123 will result in an axis of 150.

Dynamic Y-Axis Max = 

// Step 1: Find the maximum value currently displayed on the chart
VAR MaxValue =
    MAXX(
        ADDCOLUMNS(
            SUMMARIZE(
                ALLSELECTED(YourMainDataTable),      // <-- 1. CHANGE to your main data table name
                YourXAxisColumn,                     // <-- 2. CHANGE to your X-axis column
                YourLegendColumn                     // <-- 3. CHANGE to your Legend column (e.g., 'Table'[Year])
            ),
            "@ChartValue", [Your Field Parameter Measure] // <-- 4. CHANGE to your measure
        ),
        [@ChartValue]
    )

// Step 2: Add a buffer (e.g., 15%) and round up to a "nice" number
VAR PaddedValue = MaxValue * 1.15 // Adjust 1.15 for more/less padding

VAR RoundedValue =
    SWITCH(
        TRUE(),
        MaxValue = 0, 10, // Handles case where max is 0 to prevent errors
        PaddedValue > 500, ROUNDUP(PaddedValue, -2), // Rounds up to the nearest 100
        PaddedValue > 100, CEILING(PaddedValue, 50),   // Rounds up to the nearest 50
        PaddedValue > 10, CEILING(PaddedValue, 10),    // Rounds up to the nearest 10
        CEILING(PaddedValue, 5)                        // Rounds up to the nearest 5
    )

RETURN
    RoundedValue

Before this code will work, you must replace the four placeholders with the actual names from your data model. YourMainDataTable should be the name of your primary data table. YourXAxisColumn is the column on the chart's X-axis. YourLegendColumn is the field used in the Legend area, which is Year in your case. Finally, [Your Field Parameter Measure] is the measure being displayed by your field parameter; if you dragged the parameter itself to the Y-axis field well, this would be the name of that parameter measure (e.g., [Parameter]).

 

After creating the measure, you need to apply it to your visual. Select the bar chart, then go to the Format your visual pane (the paintbrush icon 🖌️). Expand the Y-axis section, and under Range, find the Maximum value box. Click the conditional formatting (fx) button next to it. In the dialog that opens, set the Format style to Field value and select your new Dynamic Y-Axis Max measure as the field. Once you click OK, your chart's Y-axis will automatically resize based on your slicer selections, giving you a clean visual every time.

 

Best regards,

Hello @DataNinja777 ,

Thank you for your response. I have an issue though, in the formula where you change the value to "your field paramter measure", mine is not a measure, it's a combination of 3 measures. The column that I created from the field parameter is actually 3 different measures. I use the column created by the field parameter select one of the measures to change the charts. Below is my DAX:

Table = {("Name1", NAMEOF([Measure1]), 0), ("Name2", NAMEOF([Measure2]), 1), ("Name3", NAMEOF([Measure3]), 2)

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors