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
Shabbir_30
New Member

Switch DAX for Date criteria

Dear All,
I am working on Attendance report in Power BI , below DAX is working fine for "P" & "WO" , but the moment i add "A" in else part of Switch, it return entire year value in table , instead of selected month from Slicer ,Any suggestion or advice much appreciate, Thank you ,

_Attendance = SWITCH(TRUE(),
COUNTROWS(FILTER(Sheet2 , Sheet2[Login Date] >= RELATED('Calendar'[Date] ) )) = 1,"P",
FORMAT(SELECTEDVALUE('Calendar'[Date]),"DDD") = "Fri" || FORMAT( SELECTEDVALUE('Calendar'[Date]),"DDD")= "Sat", "WO")

DAX not working.png

2 REPLIES 2
Shabbir_30
New Member

Thank you for your reply, 

ihave little modified DAX : SWITCH to IF , and as suggested instead of A , i have used 
so with this change , 2 things are fixed, one now its only showing selected month date, and instead of blank its is now showing "A", 
:>>> 

_Attendance = if(COUNTROWS(FILTER(Sheet2 , Sheet2[Login Date] >= RELATED('Calendar'[Date] ) )) = 1,"P",
if(FORMAT(SELECTEDVALUE('Calendar'[Date]),"DDD") = "Fri" || FORMAT( SELECTEDVALUE('Calendar'[Date]),"DDD")= "Sat","WO",
if(SELECTEDVALUE('Calendar'[Date]),"A" ))) 



now there one  thing which is slight concern,  for future date it is also showing "A", where for for future date it is expected as Blank

Shabbir_30_0-1627405039961.png

 




 

AlexisOlson
Super User
Super User

Does it help if you use SELECTEDVALUE ( 'Calendar'[Date], "A" ) instead of "A" for the else default value?

 

This should still return blanks when the date is outside of your selected range.

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.