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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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

thanks @amitchandak  the second measure is the solution!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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