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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
henry24007
Helper I
Helper I

How to make a bar chart that can control by slicers of start year and end year

I would like to make a bar chart that can control by the slicers of "Start Year" and "End Year". Pic 1 is what the slicers look like and Pic 2 is the target I would like to achieve

 

henry24007_0-1666065499982.png

 

Pic2:

henry24007_1-1666065637352.png

 

And I have made the slicer with 

Start Year = ALLNOBLANKROW('year'[year])  and
End Year = ALLNOBLANKROW('year'[year])
 
I am thinking if there any way I can make a DAX expression mixing start year and end year together and put it into my bar chart's x-axis

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @henry24007 ,

 

You can try the following to achieve the effect of dynamic axes.

Calculated_tale_Utils_ = 
VAR customer =
    SELECTCOLUMNS (
        ADDCOLUMNS (
            DISTINCT ( 'DimCustomer'[EnglishOccupation] ),
            "Type", "Profession"
        ),
        "Name", [EnglishOccupation],
        "Type", [Type]
    )
VAR product1 =
    SELECTCOLUMNS (
        ADDCOLUMNS ( DISTINCT ( 'DimProduct'[Color] ), "Type", "Color" ),
        "Name", [Color],
        "Type", [Type]
    )
RETURN
    UNION ( customer, product1 )
dynamic = 
VAR RS_Color =
    TREATAS ( VALUES ( 'Calculated_tale_Utils_'[Name] ), DimProduct[Color] )
VAR M_Color =
    CALCULATE ( [Amount_filter], RS_Color )
VAR RS_Occupation =
    TREATAS ( VALUES ( 'Calculated_tale_Utils_'[Name] ), DimCustomer[EnglishOccupation] )
VAR M_Occupation =
    CALCULATE ( [Amount_filter], RS_Occupation )
RETURN
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( 'Calculated_tale_Utils_'[Type] ) = "Color", M_Color,
        SELECTEDVALUE ( 'Calculated_tale_Utils_'[Type] ) = "Profession", M_Occupation,
        M_Color
    )

vhenrykmstf_0-1666604145569.png

vhenrykmstf_1-1666604159526.pngvhenrykmstf_2-1666604177398.png


If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.


Best Regards,
Henry


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

View solution in original post

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @henry24007 ,

 

You can try the following to achieve the effect of dynamic axes.

Calculated_tale_Utils_ = 
VAR customer =
    SELECTCOLUMNS (
        ADDCOLUMNS (
            DISTINCT ( 'DimCustomer'[EnglishOccupation] ),
            "Type", "Profession"
        ),
        "Name", [EnglishOccupation],
        "Type", [Type]
    )
VAR product1 =
    SELECTCOLUMNS (
        ADDCOLUMNS ( DISTINCT ( 'DimProduct'[Color] ), "Type", "Color" ),
        "Name", [Color],
        "Type", [Type]
    )
RETURN
    UNION ( customer, product1 )
dynamic = 
VAR RS_Color =
    TREATAS ( VALUES ( 'Calculated_tale_Utils_'[Name] ), DimProduct[Color] )
VAR M_Color =
    CALCULATE ( [Amount_filter], RS_Color )
VAR RS_Occupation =
    TREATAS ( VALUES ( 'Calculated_tale_Utils_'[Name] ), DimCustomer[EnglishOccupation] )
VAR M_Occupation =
    CALCULATE ( [Amount_filter], RS_Occupation )
RETURN
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( 'Calculated_tale_Utils_'[Type] ) = "Color", M_Color,
        SELECTEDVALUE ( 'Calculated_tale_Utils_'[Type] ) = "Profession", M_Occupation,
        M_Color
    )

vhenrykmstf_0-1666604145569.png

vhenrykmstf_1-1666604159526.pngvhenrykmstf_2-1666604177398.png


If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.


Best Regards,
Henry


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

amitchandak
Super User
Super User

@henry24007 , Same table will not so that. I have done it for month, just change logic to year. You can do with year tables in place of date tables

 

Select data between months - https://youtu.be/nEt7dT3Tfv4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

but I found that measure can't be put in the bar chart X-axis, how to solve that?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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