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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
kari1282
Helper III
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. 
 
kari1282_0-1699502491289.png

 

1 ACCEPTED SOLUTION
v-xiandat-msft
Community Support
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:

vxiandatmsft_0-1699512543517.png

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:

vxiandatmsft_2-1699512598451.png

 

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.

View solution in original post

3 REPLIES 3
v-xiandat-msft
Community Support
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:

vxiandatmsft_0-1699512543517.png

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:

vxiandatmsft_2-1699512598451.png

 

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.

Uzi2019
Super User
Super User

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

Uzi2019_0-1699506912929.png

 

I Hope I answered your question.

 

 

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

@Uzi2019  the Bonus Percent Measure is a % 

 

kari1282_0-1699512254315.png

 

 

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

 

kari1282_1-1699512352459.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors