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

Newbie: Switch DAX Function for Dates

Evening All

 

I have a date column caleld Year Completed and  if there is no date then its not completed.

 

If there is a year mentioned ; then it displays that value

 

I wanted an option like so below which I would use in a slicer for grouping of Not Completed or whatever year it completes

 

Year Completed Group = Switch(true() ,
isblank(ADMIN_MASTER[Year Completed]) , "Project Not Completed",
ADMIN_MASTER[Year Completed] = 2023, "Completed in 2023",
ADMIN_MASTER[Year Completed] = 2024, "Completed in 2024",
ADMIN_MASTER[Year Completed] = 2025, "Completed in 2025",
"Project Not Completed") 

 

jimmyg706_0-1697056634020.png

 

As you can see I have an error so Im doing something wrong?

 

Advice welcome.

 

Jimmy

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.

 

Best Regards,

Neeko Tang

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

@Anonymous    Apologies indeed I knew about the "some text" but I ahd some silly mistakes. All Good now.

 

Thanks for the advice.

 

Jimmy

 

vicky_
Super User
Super User

There's two ways to solve this:
change the type of the Year column to a number. This can be done in PowerQuery if it's just imported as part of a different dataset. If it's a calculated column, then you'll need to surround the final value with INT() or VALUE(). 

 

Or in the measure you've written above, change the 

ADMIN_MASTER[Year Completed] = 2023

to 

ADMIN_MASTER[Year Completed] = "2023"

Note there are quotes around the number.

The first method is better in my opinion, as it makes more sense for year to be an integer type.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors