Forum Discussion
Anonymous
5 years agoNot applicable
Create an if statement in a measure that returns both text and a column field
Totally new to Power BI and just can't get my head around this !! I want to create a Measure that uses an if statement in my Model Table. I can write the if statement ok I just want to return a co...
- Anonymous5 years ago
figured this out. I created a new column within the data environment and used the following syntax (which I guess was the problem all along !!.
= if('Table1'[Field1]='Table1'[Field2],"OK","Check - "&'Table1'[Field1]&" vs "&'Table1'[Field2])
Thanks for all your time and patience. As always, much appreciated.
Anonymous
5 years agoNot applicable
Hi Nate
I tried your suggestion with a test using the following:
if [Field1] = "OK" then "OK" else "Error -"& ([Field2])
Field1 is a calculation returning text "OK"
Field2 is a numerical value
This still has an orange "error" where the condition is not met with the Expression error:
Expression.Error: We cannot apply operator & to types Text and Number.
So then I tried to concatenate like so:
if [Field1] = "OK" then "OK" else "Error -"&Number.ToText([Field2])
Now I get "Error -1" but it isn't yellow and does not link to an explanation.
Any ideas?