
Anonymous
Not applicable
2016-07-29
05:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] Convert boolean to integer
Hi everyone,
I need to do diverse calculation with a column which contain boolean value, but PowerBI isn't understanding boolean as integer.
I want to add a new column in my dimension, with the integer of this boolean value but my expression is always returning 0 even for un true boolean :
lookup1.Column1.equals("1")?1:0
(Column1 is a boolean)
Does anyone know where is my mistake, or how can I do it ?
Thank's in advance,
Julien
I need to do diverse calculation with a column which contain boolean value, but PowerBI isn't understanding boolean as integer.
I want to add a new column in my dimension, with the integer of this boolean value but my expression is always returning 0 even for un true boolean :
lookup1.Column1.equals("1")?1:0
(Column1 is a boolean)
Does anyone know where is my mistake, or how can I do it ?
Thank's in advance,
Julien
500 Views
1 Solution
Accepted Solutions

Champion II
2016-07-29
05:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If the datatype of lookup1.Column1 is boolean, you should write
Regards,
TRF
If the datatype of lookup1.Column1 is boolean, you should write
lookup1.Column1 ? 1 : 0
Regards,
TRF
500 Views
5 Replies

Champion II
2016-07-29
05:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If the datatype of lookup1.Column1 is boolean, you should write
Regards,
TRF
If the datatype of lookup1.Column1 is boolean, you should write
lookup1.Column1 ? 1 : 0
Regards,
TRF
501 Views

Anonymous
Not applicable
2016-07-29
05:48 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank's a lot
It does work, but can you just explain me why please ? I'm a Java novice and I'd like to understand.
Thank's in advance,
Julien
Thank's a lot
It does work, but can you just explain me why please ? I'm a Java novice and I'd like to understand.
Thank's in advance,
Julien
500 Views

Anonymous
Not applicable
2016-07-29
05:55 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a Java ternary operator and is equivalent to: -
if(lookup1.Column1) 1; else 0;
but you can't easily use an if statement in a mapping expression.
If you mean, why does you way not work, take a look at the Java help for Boolean.equal()
if(lookup1.Column1) 1; else 0;
but you can't easily use an if statement in a mapping expression.
If you mean, why does you way not work, take a look at the Java help for Boolean.equal()
500 Views

Champion II
2016-07-29
06:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's it!
500 Views

Anonymous
Not applicable
2016-07-29
06:13 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank's a lot to both of you !!
500 Views
