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! Learn more

Reply
Anonymous
Not applicable

How to modify the Slicer to show range of month based on month selected in another slicer

Hi 

 

My ask is how to modify the Slicer (Month name ) to show range of month based on month selected in another slicer.

For example:

If i select year to be 2023 & Month to be May in a slicer from data table, it have to modify the another month slicer in fact table to show Jan to May not just may.

 

Any help is welcomed.

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Anonymous ,

My suggestion involves establishing an additional Dates table without a relationship to the primary Dates table (disconnected). Subsequently, you can create a measure to assess whether the dates in the primary Dates table fall within a defined range. This measure will yield a blank result if the date is outside the specified range, enabling the slicer to be visually filtered to exclude blanks.

 

Here's a sample measure:

DateFilter = 
VAR __X_MONTHS = 5 //x months from EOMONTH
VAR __EOMONTH =
    EOMONTH ( MAX ( Dates2[Date] ), 0 ) //selected month's end of month
VAR __START =
    EDATE ( __EOMONTH, - __X_MONTHS ) + 1
RETURN
    CALCULATE (
        COUNTROWS ( Dates ),
        FILTER ( Dates, Dates[Date] >= __START && Dates[Date] <= __EOMONTH )
    )

 

danextian_0-1705400566496.png

Note: This approach does not work if the slicer is set to Between (bug!)

Please see attached pbix for your reference.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

You can try dax formula like below

StartDate = 
   MINX(
      FILTER(
         'DateTable',
         'DateTable'[Year] = SELECTEDVALUE('Year-Month Slicer'[Year1]) &&
         'DateTable'[MonthNum] = SELECTEDVALUE('Year-Month Slicer'[MonthNum1])
      ),
      'DateTable'[Date]
   )
MonthRange = 
CALCULATE(
    IF(
        COUNTROWS(
            FILTER(
                'DateTable',
                'DateTable'[Date] >= [StartDate] && 'DateTable'[Date] <= MAX('DateTable'[Date])
            )
        ) > 0,
        1,
        0
    )
)

vkongfanfmsft_0-1705478304069.png

 

Best Regards,
Adamk Kong

 

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 @danextian 

 

Thanks a lot for quick response , 

Yes this method work well but small thing instead of having fixed x months, i have to show from jan to till the selected month.

How can this be done. i am thinking about creating a switch condition to put the value for x : for ex if april is selected x will be 4, may then x is 5 likewise for all 12 months. is there any simple alternative approach you can suggest.

You can just change the __START varible either by hardcoding the full date or by hardcoding just the month and day.

VAR __START = 
    DATE ( YEAR ( EOMONTH ), 1 , 1 )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @Anonymous ,

My suggestion involves establishing an additional Dates table without a relationship to the primary Dates table (disconnected). Subsequently, you can create a measure to assess whether the dates in the primary Dates table fall within a defined range. This measure will yield a blank result if the date is outside the specified range, enabling the slicer to be visually filtered to exclude blanks.

 

Here's a sample measure:

DateFilter = 
VAR __X_MONTHS = 5 //x months from EOMONTH
VAR __EOMONTH =
    EOMONTH ( MAX ( Dates2[Date] ), 0 ) //selected month's end of month
VAR __START =
    EDATE ( __EOMONTH, - __X_MONTHS ) + 1
RETURN
    CALCULATE (
        COUNTROWS ( Dates ),
        FILTER ( Dates, Dates[Date] >= __START && Dates[Date] <= __EOMONTH )
    )

 

danextian_0-1705400566496.png

Note: This approach does not work if the slicer is set to Between (bug!)

Please see attached pbix for your reference.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
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!

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