Skip to main content
Solved

Multi IF/OR and fields ?


Forum|alt.badge.img+6

Hello community!

I am looking to display the amount of an hour of additional service to be applied to a price depending on the type of service (A, B, C or D).

This number of hours can be 0, 1 or 2.

I have already created a column that automatically displays the number of hours to be invoiced (0, 1 or 2).

I have already created a column that automatically displays the type of service (A, B, C or D).

Here are the possible scenarios :

- If my hours column displays 0h and the product type is A, B, C or D, then display 0 â‚¬
- If my hours column displays 1h or 2h, and the product type is A, then display 10 €
- If my hours column displays 1h or 2h, and the product type is B, then display 20 €
- If my hours column displays 1h or 2h, and the product type is C, then display 30 €
- If my hours column displays 1h or 2h, and the product type is D, then display 40 €

Can you help me please ?

Best answer by Justin_Barrett

 

 

IF( hours, SWITCH( {Product Type}, "A", 10, "B", 20, "C", 30, "D", 40 ), 0 )

 

 

Here's how that breaks down. The IF() function will execute the SWITCH() function only if the {hours} field returns a non-zero number (non-zero numbers are considered to be truthy; i.e. equivalent to True); otherwise it defaults to an output value of 0.

The SWITCH() function creates specific output based on the option chosen in the {Product Type} field.

View original
Did this topic help you find an answer to your question?

2 replies

Justin_Barrett
Forum|alt.badge.img+20
  • Inspiring
  • 4647 replies
  • Answer
  • December 6, 2022

 

 

IF( hours, SWITCH( {Product Type}, "A", 10, "B", 20, "C", 30, "D", 40 ), 0 )

 

 

Here's how that breaks down. The IF() function will execute the SWITCH() function only if the {hours} field returns a non-zero number (non-zero numbers are considered to be truthy; i.e. equivalent to True); otherwise it defaults to an output value of 0.

The SWITCH() function creates specific output based on the option chosen in the {Product Type} field.


Forum|alt.badge.img+6
  • Author
  • Inspiring
  • 11 replies
  • December 6, 2022

Just perfect, thank you ! @Justin_Barrett !!


Reply