cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Helper III

## Creating an IF measure that returns text

Hi I have the following measure that I belive is correct:

Bonus Tier =
IF([Bonus Percentage Measure]>=1.05 && [Bonus Percentage Measure]<1.1, "Tier 1",
IF([Bonus Percentage Measure]>=1.1 & [Bonus Percentage Measure]<1.5, "Tier 2",
IF([Bonus Percentage Measure]>=1.5 && [Bonus Percentage Measure]<1.2, "Tier 3",
IF([Bonus Percentage Measure]>=1.2, "Tier 4"))))

However, I keep getting the below error, I'm a little confused because Bonus Percentage Measure is a perntage and I'm not comparing text at all I just want the out put to be text.

1 ACCEPTED SOLUTION
Community Support

Hi @kari1282 ,

You need to use double ampersand '&&' between your logical arguments. A single ampersand simply tries to concatenate text.

I'd also recommend using the SWITCH function in place of your nested IF statements as it makes the code easier to read.

Below is my table:

The following DAX might work for you:

``````Measure =
var Bonus_Percentage_Measure = SELECTEDVALUE('Table'[Bonus Percentage Measure])
var result =
SWITCH(
TRUE(),
Bonus_Percentage_Measure>=1.05 && Bonus_Percentage_Measure < 1.1 ,"Tier 1",
Bonus_Percentage_Measure>=1.1 && Bonus_Percentage_Measure < 1.5 , "Tier 2",
Bonus_Percentage_Measure>=1.5 && Bonus_Percentage_Measure < 2.2 , "Tier 3",
Bonus_Percentage_Measure >= 2.2 , "Tier 4"
)
return result
``````

The final output is shown in the following figure:

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Community Support

Hi @kari1282 ,

You need to use double ampersand '&&' between your logical arguments. A single ampersand simply tries to concatenate text.

I'd also recommend using the SWITCH function in place of your nested IF statements as it makes the code easier to read.

Below is my table:

The following DAX might work for you:

``````Measure =
var Bonus_Percentage_Measure = SELECTEDVALUE('Table'[Bonus Percentage Measure])
var result =
SWITCH(
TRUE(),
Bonus_Percentage_Measure>=1.05 && Bonus_Percentage_Measure < 1.1 ,"Tier 1",
Bonus_Percentage_Measure>=1.1 && Bonus_Percentage_Measure < 1.5 , "Tier 2",
Bonus_Percentage_Measure>=1.5 && Bonus_Percentage_Measure < 2.2 , "Tier 3",
Bonus_Percentage_Measure >= 2.2 , "Tier 4"
)
return result
``````

The final output is shown in the following figure:

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

Hi @kari1282
Please check wether you Measue is in % or not.( Basically should not a text)

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Helper III

@Uzi2019  the Bonus Percent Measure is a %

I think the problem is the Bonus Tier the measure I wrote is showing as General. I do not see an option to change the format to text

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors