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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Switch condition (or) If and Else If to handle both conditions in a single measure.

Hi,

 

Need help on writing  Switch condition  (or)  If and Else If  to handle both conditions in a single measure.   I tried as below but there is an issue.   Attached the screenshot.

 

 

If Else condition.png

 

SlicerCheck =
IF( ISFILTERED(VehicleTrend[Report Date]),BLANK(),"Please select Report Date")
OR
IF( DISTINCTCOUNT(VehicleTrend[Report Date]) = 1 ,"","Please select Report Date")

2 ACCEPTED SOLUTIONS
v-lili6-msft
Community Support
Community Support

hi,@v_krishna

        you can try to use this measure:

new SlicerCheck = 
var a1=CALCULATE(DISTINCTCOUNT(VehicleTrend[ReportDate]),ALLEXCEPT(VehicleTrend,VehicleTrend[ReportDate])) return
IF(ISFILTERED(VehicleTrend[ReportDate])=BLANK() || a1> 1 ,"Please Select a Report Date", BLANK())

Then set visual level filter is blank

2.PNG

Result:

3.PNG

4.PNG

 

Best Regards,

Lin

Community Support Team _ Lin
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

Anonymous
Not applicable

Thank you for the solution Lin.  It works as expected.

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi,@v_krishna

        you can try to use this measure:

new SlicerCheck = 
var a1=CALCULATE(DISTINCTCOUNT(VehicleTrend[ReportDate]),ALLEXCEPT(VehicleTrend,VehicleTrend[ReportDate])) return
IF(ISFILTERED(VehicleTrend[ReportDate])=BLANK() || a1> 1 ,"Please Select a Report Date", BLANK())

Then set visual level filter is blank

2.PNG

Result:

3.PNG

4.PNG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the solution Lin.  It works as expected.

v-lili6-msft
Community Support
Community Support

hi,@v_krishna

    You may try to use ||  in your formula:

SlicerCheck = 
IF(ISFILTERED(VehicleTrend[Report Date])|| DISTINCTCOUNT(VehicleTrend[Report Date]) = 1 ,BLANK(),"Please select Report Date")

Best Regards,

Lin

Community Support Team _ Lin
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,

 

Intially i have implemented a measure based on the requirement. 

 

SlicerCheck = IF( ISFILTERED(VehicleTrend[Report Date]),BLANK(),"Please select Report Date")

 

please refer the below link for details .

https://community.powerbi.com/t5/Desktop/Empty-Line-and-Stacked-column-chart-with-a-slicer-and-displ...

 

I had to update the above measure (refer the update measure below) to accomodate other conditions but facing the issue.  Out of 3 conditions, 1st and 2nd conditions are working and 3rd condition is failing.

 

SlicerCheck =IF(ISFILTERED(VehicleTrend[Report Date])=BLANK() || DISTINCTCOUNT(VehicleTrend[Report Date])> 1 ,"Please Select a Report Date", BLANK())

 

1) When user select only one of the Report Date from the slicer, the Line chart data is displayed.  Below is the working behavior mockup.

 

message3.png

 

2)  When none of the Report Date is selected from the slicer, the Line chart is set blank with a message displayed. 

Below is the working behavior mockup.

 

message2.png

 

3) Issue is here:  If User tries to select more than one Report Date fron the slicer, the expected behaviour is the Line chart should be set to blank with a message displayed  BUT there is issue. below is the mockup for reference.

 

message5.png 

 

 

i feel this might be causing the issue but not sure.   In the Line chart visuvalization  - SlicerCheck measure is applied to Visual filters and it is set to blank. Refer the mockup below. 
But now the measure has other condition added "DISTINCTCOUNT(VehicleTrend[Report Date])> 1" . so is this causing the issue  for 3rd condition please assist on this

 

 message4.png

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!

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