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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
rsanyoto
Helper III
Helper III

Switch true can not convert text with integer

Hi guys,

I have the following measure:

MeasureXXX =
SWITCH( TRUE(),
VALUES(DimDate[year])= "2019", [Total Employee 2019],
VALUES(DimDate[year])= "2020", [Totaal Employee2020],
BLANK())
 
Unfortunatly i received the following error message:
 
rsanyoto_0-1617893770586.png

 

 

the column year has the data type whole number and the two measures of total employee 2019 and total employee 2020 are created as follows:

 
total employee 2019= CALCULATE(DISTINCTCOUNT('Bezetting'[Personeelsnummer]),
FILTER(Bezetting,Bezetting[month]=DATE(2019,12,1)))
 
total employee 2020 = CALCULATE(DISTINCTCOUNT('Bezetting'[Personeelsnummer]),
FILTER(Bezetting,Bezetting[month]= MAX('Bezetting'[month])))
 
Any suggestions? many thanks
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@rsanyoto , check datatype of year once

 

Try like

 

MeasureXXX =
SWITCH( TRUE(),
VALUES(DimDate[year])= 2019, [Total Employee 2019],
VALUES(DimDate[year])= 2020, [Totaal Employee2020],
BLANK())

 

or

 
MeasureXXX =
SWITCH( TRUE(),
max(DimDate[year])= 2019, [Total Employee 2019],
Max(DimDate[year])= 2020, [Totaal Employee2020],
BLANK())

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@rsanyoto , check datatype of year once

 

Try like

 

MeasureXXX =
SWITCH( TRUE(),
VALUES(DimDate[year])= 2019, [Total Employee 2019],
VALUES(DimDate[year])= 2020, [Totaal Employee2020],
BLANK())

 

or

 
MeasureXXX =
SWITCH( TRUE(),
max(DimDate[year])= 2019, [Total Employee 2019],
Max(DimDate[year])= 2020, [Totaal Employee2020],
BLANK())

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  the second measure is the solution!!!

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Kudoed Authors