Nested If Then statement? Help

Thanks for any help in advance. Seems like something that should be easy, however I’m not finding any solution while searching.

I have an input that return’s a person’s birthdate formatted as YYYY in an input field called ‘Input Pension BY’. In another input field I want to capture a number (age) based on the BY.

As a more experienced Excel user I would have a nested if/then statement, something like: IF(BY<=1964,56,IF(BY=1965,56.2,IF(BY=1966,56.4,IF(BY=1967,56.6,IF(BY>=1968,57,0)))))

I used my local AI for help and said I couldn’t use an input field but to use a text field. Here’s the JSON code my AI gave me to paste into the text field:

IF (Input Pensions BY <= 1964) THEN {
MRA = 64;
} ELSE IF (Input Pensions BY == 1965) THEN {
MRA = 56.2;
} ELSE IF (Input Pensions BY == 1966) THEN {
MRA = 56.4;
} ELSE IF (Input Pensions BY == 1967) THEN {
MRA = 56.6;
} ELSE IF (Input Pensions BY == 1968) THEN {
MRA = 56.8;
} ELSE IF (Input Pensions BY == 1969) THEN {
MRA = 56.1;
} ELSE IF (Input Pensions BY >= 1970) THEN {
MRA = 57;
}

I changed the plain text of Input Pensions BY into dynamic data as Input Pensions BY’s value, but when I preview it just shows the code as text and not calculating anything.

A way to perform nested if / else checks is to do:

Input Pensions BY ≤ 1964:formatted as text → then you can further perform calculations / operations for yes & for no values. Each value that you generate can be further nested and so on. Downside of that is that it only returns a text at the end. But you can format this back as a number again if you need the 64 / 56.2 etc. values as float

I’d advise that you do that within a hidden input / text element in the Frontend as when performed in workflows and used as returnvalue, sometimes it will not further go into nested conditions or the Workflow cannot use the returned text properly as value to process data so best to transform the input into a usable value on the Client and then use these inputs for further processing.

Hope this helps

Thanks for the assistance. I’ll try your suggestion and see if it works.

did it work?

You can do it with options sets easier and more flexible for future. See the demo below:
chrome_iSQSGTwjJ7

Simply, there is an option set for setting MRA values and upper and lower limits:

Then, you will add your MRA values:
chrome_qD6vWuOoML

And finally, in your page, you will get all MRA option set values and filter them based on the input:

See the editor here: Tests for Forum 14 | Bubble Editor

Wasn’t able to work on it. Got caught up with actual work and not the side project.

Thanks for the detailed response. I’ll definitely look into tomorrow.

Thanks hergin. Using option sets and attributes worked. I’ll make sure to start utilizing the attributes in my other option sets.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.