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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Else If Custom Column issue

Hey all,

 

I am having an issue with my If statement in a custom Column.

 

The below is suppose to give a percentage based on the total spend, but instead it just gives the first percentage of .16 to everything no matter what their total spend is.

 

if([RadarService] = 2) then
if[PretaxCharges] < 5000 then .16
else if[PretaxCharges] > 5000 then .15
else if[PretaxCharges] > 10000 then .14
else if[PretaxCharges] > 20000 then .14
else if[PretaxCharges] > 30000 then .13
else if[PretaxCharges] > 40000 then .13
else if[PretaxCharges] > 60000 then .12
else if[PretaxCharges] > 80000 then .12
else if[PretaxCharges] > 100000 then "Quote Needed" else null else null)

Any reason why it's just ignoring the other else if statements?

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

You will need to reverse the order of your else IF Expressions.

Once an if expression condition is met, it stops executing the rest of IF expressions.

 

So if your PretaxCharges are more than 100,000 they are also more tham 5000 as well

So this expression is executed since it appears first

if[PretaxCharges] > 5000 then .15


Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Update: I've managed to solve my issue.

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

You will need to reverse the order of your else IF Expressions.

Once an if expression condition is met, it stops executing the rest of IF expressions.

 

So if your PretaxCharges are more than 100,000 they are also more tham 5000 as well

So this expression is executed since it appears first

if[PretaxCharges] > 5000 then .15


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Hey, thanks for your reply!

 

The issue is it's not the greater than step that's doing it, it's the very first one which is "If it's less than 5000" at the very top. Now I tried reversing it with no luck, everything is still getting set to .16 

@Anonymous

 

When i use some random data  with your formula... I dont get 0.16 every time.

 

 

ifthenesle.png


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Okay so I think I found the problem, I have summed PreTaxCharges because in the table it's 1000s of lines and each line has a different price for each client.

 

The reason I think I'm getting .16 for everything is that all charges are actually less than 5000 when they are not summed and I think my custom column is looking at the user's individual line item price rather than the sum?

 

 

Anonymous
Not applicable

Yea I am confused on where the issue is here.

 

Capture.PNGThe top one should be .16 as it's below 5k but the others shouldn't be. I don't see what it's looking at, as it should just compare that spend with the if statements

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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