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
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")

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
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.