Post

1 follower Follow
0
Avatar

Conditional Format Aplication

Hi, I wanted to know how can i make a calculation with a conditional statement. What i need to do is to execute is a calculation that allows me to sum a range of other fields; and if the statement is false this field performs another different calculation.

Is this possible?

Regards.

Jester Chávarry

Jester Chavarry

Please sign in to leave a comment.

12 comments

0
Avatar

Hey Jester,

This should be possible via Javascript yes - if (condition) {action1} else {action2};

Can this work?

Cheers,
Sara

Sara Høeg Højlund-Rasmussen 0 votes
0
Avatar

Hi Sara,

I've tried what you told me, but the thing is that i didn't get the result i needed.

In my case, the calculation should be the following:
if (Category Field=True Value) {action 1} else {action 2}

Thank you for your time.

Regards.

Jester Chavarry 0 votes
0
Avatar

Perhaps you can write the entire calculation to help us understand what is not working?

It is important that you are familiar with Javscript for it to work :)

//Sara - Podio

Sara Høeg Højlund-Rasmussen 0 votes
0
Avatar

Of Course Sara:

First of all, the category field titled "Incentiva a la renuncia" has two options.
"Aplica" y "No Aplica"

In this case, what i need to do is to apply a calculation if the statement is true, and another if it is false.

The details are displayed below:

if (Incentiva a la renuncia:="Aplica") {0} else {(EC NEG - Uso de gancho:*0.12*100)+(EC NEG - Sondeo:*0.05*100)}

For the example,the fields called "EC NEG - Uso de gancho:" and "EC NEG - Sondeo:" are Numbers, which already show us the result we need.

Thank you for your time.

Regards.

Jester Chavarry 0 votes
0
Avatar

Hi Sara; Do you have the response for my question please?

Regards.

Jester Chavarry 0 votes
0
Avatar

Do you get any error message? I'm afraid it is quite difficult to see from here without access to your apps and workspaces or error message :(

I just tested myself using if(Number1==="1"){100}else{200} and it seems to work :)

You need to add "===" as = is an assignment operator, not a comparison :) I should have added this in the code description above! Will add it now.

Sara Høeg Højlund-Rasmussen 0 votes
0
Avatar

Hi Sara, i have another question in the statement i'm giving to the calculation i need to get the result in text format, this because i need to display the "%" symbol.

How can i get this result if the statement in both cases, when it is true or false? when I execute the standard calculation i get the message "The result is not a valid number". Just Because I added +"%" to the formula i am using.

Please help me to get this right.

Thanks for your time.

Regards.

Jester Chavarry 0 votes
0
Avatar

I think you can work-around this by making the output of the calculation a text and forcing the unit at the front of the calculation. Something like:

"%" + (@number1 + @number2)

as example

But one problem with this is that you lose control of the number of decimal places that are displayed, because this is not an option in calculations with text output. You can control this by using a javascript function toFixed() like this:

"$" + (@number1 + @number2).toFixed(2)
The brackets are important in both cases (they should be around the numbers). The 2 inside the brackets at the end is the number of decimal places you need.

Sara Høeg Højlund-Rasmussen 0 votes
0
Avatar

Hello Sara:

I've tried including the "%" symbol inside my calculation but i'm not able to save the changes because I get the following message "The type of result changed from number to text."

Just to be sure that i explained myself right i let you the statement I´m trying to use.

if(Incentiva a la renuncia:==="Aplica") {(0)+"%"} else {(1)+"%"}

I also tried the statement without the brackets, but i got the same error.

Please help me ASAP it´s the last thing i need to get this done.

Thanks for your time.

Regards.

Jester Chavarry 0 votes
0
Avatar

Hi Sara.

Sorry to bother, but I wanted to know if you have some news for me.

Thank you.

Regards.

Jester Chavarry 0 votes
0
Avatar

Hi Sara, I need to know if you have more information for me please.

Jester Chavarry 0 votes
0
Avatar

Hey Jester,

Sorry for the delay - if you like fast feedback from us in the future I recommend that you click "Contact support" in top right corner and we can follow up with you the same day :)

You get this error because you cannot change the output of a calculation field after saving the field the first time.

Can you try to add a new calculation field? Then it will be possible to use the text output :)

//Sara - Podio

Sara Høeg Højlund-Rasmussen 0 votes