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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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