Skip to main content
Answer

Variable Style IIF Expression

  • April 15, 2025
  • 3 replies
  • 107 views

Forum|alt.badge.img+1

I have a slightly weird question.

Can I have multiple IIF expressions within one field?

 

It seems possible, but I am not sure how to accomplish this.

 

I would like to change the cell style based on the text inside of it.

 

But the system does not like me adding another IIF statement within my expression.

 

This is what I have right now to keep it simple, but once I can get it to work, I will add a couple more colors.

 

=IIf( [InventoryItem.PreferredVendorID]='100045', 'purple20', 'default') OR

IIf( [InventoryItem.PreferredVendorID]='100351', 'yellow20',' default') 

 

 

The System doesn’t like my OR placement, does anyone know a better way to do this?

Best answer by davidnavasardyan

Hi ​@bodiec 

You can absolutely use multiple IIf statements, but you’ll need to nest them properly—no OR between them. Try this structure instead:

=IIf([InventoryItem.PreferredVendorID]='100045', 'purple20', 
IIf([InventoryItem.PreferredVendorID]='100351', 'yellow20',
'default'))

Just keep stacking them like that if you need more conditions. It’s basically like a fancy "else if" chain.

3 replies

lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • April 15, 2025

Hi ​@bodiec ,

You can nest the IIf statements, but easiest is to use Switch instead, something like this:

=switch( [InventoryItem.PreferredVendorID]='100045', 'purple20',  [InventoryItem.PreferredVendorID]='100351', 'yellow20', 1=1, 'default') 

Hope this helps!

Laura


davidnavasardyan
Jr Varsity I
Forum|alt.badge.img+3

Hi ​@bodiec 

You can absolutely use multiple IIf statements, but you’ll need to nest them properly—no OR between them. Try this structure instead:

=IIf([InventoryItem.PreferredVendorID]='100045', 'purple20', 
IIf([InventoryItem.PreferredVendorID]='100351', 'yellow20',
'default'))

Just keep stacking them like that if you need more conditions. It’s basically like a fancy "else if" chain.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro II
  • April 15, 2025

Thank you both very much!

@davidnavasardyan ​@lauraj46