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
kkalyanrr
Helper V
Helper V

Measure to show/hide a value based on slicer selections(MultipleSelections)

Hello,

 

I'm looking for a measure, where in we select continuous months then the measure should work , if we select the months which are not in sequential order measure should show blank value.

For eg: measure shld work when we select Jul and Aug..it shld return zero value when we select Jul and Sep.
I tried using hasonevalue function , but it works with only one month at a time.

Capture.PNG

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

@kkalyanrr , the logic is a bit verbose to test whether selected items are in a row; you might try this pattern, (assume your Calendar table is like this)

Screenshot 2020-12-08 164216.png

 

Test Consecutive = 
VAR __mth_selected = COUNTROWS ( ALLSELECTED ( 'Calendar'[Year-Month] ) )
VAR __period = ALLSELECTED ( 'Calendar' )
VAR __mth_min = MONTH ( MINX ( __period, 'Calendar'[Date] ) )
VAR __mth_max = MONTH ( MAXX ( __period, 'Calendar'[Date] ) )
VAR __consecutive = __mth_max - __mth_min + 1 = __mth_selected
RETURN
    IF ( __consecutive, "Consecutive", "Not Consecutive" )

 

Screenshot 2020-12-08 164558.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

@kkalyanrr , the logic is a bit verbose to test whether selected items are in a row; you might try this pattern, (assume your Calendar table is like this)

Screenshot 2020-12-08 164216.png

 

Test Consecutive = 
VAR __mth_selected = COUNTROWS ( ALLSELECTED ( 'Calendar'[Year-Month] ) )
VAR __period = ALLSELECTED ( 'Calendar' )
VAR __mth_min = MONTH ( MINX ( __period, 'Calendar'[Date] ) )
VAR __mth_max = MONTH ( MAXX ( __period, 'Calendar'[Date] ) )
VAR __consecutive = __mth_max - __mth_min + 1 = __mth_selected
RETURN
    IF ( __consecutive, "Consecutive", "Not Consecutive" )

 

Screenshot 2020-12-08 164558.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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
Top Kudoed Authors