You are viewing limited content. For full access, please sign in.

Question

Question

Is it possible to have three IF formulas in one field?

asked on December 5, 2023

I'm very new to Forms calculations. Can anyone tell me if having three IF formulas in one field is possible? I'm working on a way to calculate a pay rate based on the number of students in a class. If it's more than 15, it's one rate, if it's more than 20, it's a different rate, and if it's over 25, it's a third rate. So I guess there are 4 effective rates. 

This is what I have so far: 

=IF(table.crs_enroll>15,"0","Enroll16"); 
&IF(table.crs_enroll<20,"Enroll21","Enroll16"); 
&IF(table.crs_enroll<25,"Enroll26","Enroll21");

Saving that formula doesn't indicate a syntax error, but it also returns results for all three formulas, which isn't helpful. Is there an IF/THEN syntax in Laserfiche forms?

What would be a better way to do this? 

 

0 0

Replies

replied on December 6, 2023

You can nest your IF statements using this format:

  • AND – =IF(AND(Something is True, Something else is True), Value if True, Value if False)

  • OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False)

  • NOT – =IF(NOT(Something is True), Value if True, Value if False)

If that doesn't get you all the way there, you can use hidden fields to store your comparisons and then compare the hidden fields.

I hope that helps!

1 0
replied on December 6, 2023

You can nest the IFs since they already have "if/else" functionality.

There's multiple ways you can set it up, but basically just pick one of the range as the first IF and handle the subsequent checks in the true/false sections.

For example,

=IF(condition, true, false)

You can make the true or false parameter be another IF which gives you a way to check ranges

=IF(value > 100, "Above 100", IF((value > 50, "Above 50", "Default"))

In this example, if the value is above 100, it uses the true value which is the "Above 100" text, however, if it is less than or equal to 100, it moves onto the next IF function.

So basically, just pick the value you want to check for first, if that fails, check the next range, and so on until you either find a match or hit your "default" value at the end.

1 0
replied on December 5, 2023

Hi Travis,

You might want to use custom JavaScript to make it easier to calculate the field.

With classic form, you can click "CSS and JavaScript" tab to insert your JavaScript.

With modern form, you can control it via The LFForm Object, you can find more here.

 

You are not allowed to follow up in this post.

Sign in to reply to this post.