Post

2 followers Follow
0
Avatar

Percentage Calculation

Hello, I am trying to calculate the status of our clients to see the percentage of client retention rate.

One one calculation section, I would like:
if Status = Active then +1
If Status = Closed then -1

I have been doing this:
if (@Status = "Active")+1
if (@Status = "Closed")-1

But it just marks everything as -1 or 1 depending on the order it is put in.

Thank you!

Natalie N.

Please sign in to leave a comment.

2 comments

1
Avatar

Hi Natalie,

the syntax of the IF is wrong:

var result = 0;
if(@Status == "Active"){
result = 1;
} else if(@Status == "Closed"){
result = -1;
};
result

or in shorthand format (which I prefer):

@Status == "Active" ? 1 : @Status == "Closed" ? -1 : 0;

If you want to check if a value is equal to another value you must use double equal signs: == 
not equal is: != 
Also: If want want a positive number to be returned you don't need the + before the number.

The above codes are for single choice categorie fields (but I assume it's a single choice); for multi choice fields the code must be modified a bit.

Rainer 

Rainer Grabowski 1 vote
0
Avatar

Hi Rainer, 

That worked. Thank you.

Can you help me turn this into a percentage so that I can see percentage of closed vs active?

Natalie N. 0 votes