Conversion failed when converting the nvarchar value to data type bit Report Builder

41 Views Asked by At

I have a query that I use in a Report Builder. The query in Maindataset

select 
customer_id
,first_name
,last_name
,case when customer_gender=0 then 'Man' 
when customer_gender=1 then 'women'
else null as gender 
,phone
,email
,city
from [customers] 

Becuase I want add Gender as parameter (Appear As Man and Women), I already create Genderdataset

select
case when customer_gender=0 then 'Man' 
when customer_gender=1 then 'women'
else null as G
from [customers]

when I click on run, the error message appear

conversion failed when converting the nvarchar value 'Man' to data type bit.

THANKS

1

There are 1 best solutions below

1
James Laycock On

Either Report builder is trying to put the result of that case statement into a bit field, or it has an expression that is expecting a bit field that is using this field. instead of replacing the original field, add a new field with the result of your case statement and change the expression where you display it to use this field instead of the old field.

select customer_id
    ,first_name
    ,last_name
    ,customer_gender as gender 
    ,case when customer_gender=0 then 'Man' 
    when customer_gender=1 then 'women'
    else null as genderText 
    ,phone
    ,email
    ,city
    from [customers]