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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
walker4545
Frequent Visitor

Cannot convert value of type Text to type Integer.

Hi PowerBI community, 
I'm attempting to use a Switch Statement in DAX to create customised column of categories using 'Proposed Start Date' dates (in date format) for travel bookings:
 
Proposed Travel Start Half Year =
VAR PropYear = YEAR('TravelBookings'[Proposed Start Date])
VAR PropMonth = MONTH('TravelBookings'[Proposed Start Date])
VAR PropHalfYear = SWITCH(PropMonth,
1, "First Half of Year", 2, "First Half of Year", 3, "First Half of Year", 4, "First Half of Year", 5, "First Half of Year", 6, "First Half of Year", 7, "Second Half of Year", 8, "Second Half of Year", 9, "Second Half of Year", 10, "Second Half of Year", 11, "Second Half of Year", 12, "Second Half of Year", "")
VAR PropHalfYearAndYear = PropHalfYear & " " & PropYear

RETURN PropHalfYearAndYear
 
The error message that I get returned is the following:
 
Cannot convert value 'First Half of Year 2023' of type Text to type Integer.
 
Can anyone assist me with this and let me know where I'm going wrong?
 
Thanks in advance!
1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @walker4545 ,

 

It looks like this is because the column previously returned values of Whole number type, causing an error when the output is text. Please select the calculated column and change the format to text.

 

vkkfmsft_0-1653981118684.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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
v-kkf-msft
Community Support
Community Support

Hi @walker4545 ,

 

It looks like this is because the column previously returned values of Whole number type, causing an error when the output is text. Please select the calculated column and change the format to text.

 

vkkfmsft_0-1653981118684.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@walker4545 ,  I did not see PropSemester

 

Also PropSemester & " " & PropYear is string to general number will not apply

 

 

VAR PropHalfYearAndYear = PropSemester & " " & FORMAT(PropYear, "General Number")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak and apologies, I had the wrong data label included in my sample above. It's been corrected now. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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