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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Axis Range change dynamically Based on slicer value

Hello,

 

I have a requirement to take a survey of the population based on age. While using slicers from 0 to 10, the x-axis value of the chart show 0-10,10-20,20-30...etc.based on ages in data .Likewise, my slicer value is 0 to 30 means, the x-axis value of the chart show 0-30,60-90,....etc.In X-axis the age should show data dynamically based on slicer values.WhatsApp Image 2021-08-03 at 12.06.12 PM.jpeg

 

 

 This is a sample of what I want to do. Please help to rectify this one. Thanks in Advance.

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Sorry...You may create a new thread in Power BI Desktop Community to get further help.😅

 

Best Regards,
Eyelyn Qin

 

v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on my test, I created two Range tables and used Bookmarks to realize your scenario.

 

Here is my data samples.

all needed tables.PNG

Step1:  Create two measures for each range:

Range is 10 =
SWITCH (
    MAX ( 'Range(10)'[Range] ),
    "0-10",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] >= 0 && 'Age Table'[Age] <= 10 )
        ),
    "10-20",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 10 && 'Age Table'[Age] <= 20 )
        ),
    "20-30",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 20 && 'Age Table'[Age] <= 30 )
        ),
    "30-40",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 30 && 'Age Table'[Age] <= 40 )
        ),
    "40-50",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 40 && 'Age Table'[Age] <= 50 )
        ),
    "50-60",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 50 && 'Age Table'[Age] <= 60 )
        ),
    "60-70",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 60 && 'Age Table'[Age] <= 70 )
        ),
    "70-80",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 70 && 'Age Table'[Age] <= 80 )
        ),
    "80-90",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 80 && 'Age Table'[Age] <= 90 )
        ),
    "90-100",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 90 && 'Age Table'[Age] <= 100 )
        )
)
Range is 30 =
SWITCH (
    MAX ( 'Range(30)'[Range] ),
    "0-30",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] >= 0 && 'Age Table'[Age] <= 30 )
        ),
    "30-60",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 30 && 'Age Table'[Age] <= 60 )
        ),
    "60-90",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 60 && 'Age Table'[Age] <= 90 )
        ),
    "90-100",
        CALCULATE (
            COUNTROWS ( 'Age Table' ),
            FILTER ( 'Age Table', 'Age Table'[Age] > 90 && 'Age Table'[Age] <= 100 )
        )
)

Step2: Create visuals on two pages and use each page as bookmark like this:

page1 as bookmark1.PNGpage2 as bookmark2.PNG

The final output is shown below:

dynamic change.gif

 

Refer to:

Create report bookmarks in Power BI to share insights and build stories - Power BI | Microsoft Docs

 

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

Anonymous
Not applicable

Hi @v-eqin-msft 

Thanks for your response,this one make my work very easily.

One more question is there any way to use this one on same page without using bookmark,

beacause my requirement is x-axis value change dynamicaly based slicer value on same graph.I am new to power bi can you please help to get this one.

Thanks in advance

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors