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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.