3 Replies Latest reply on Jul 5, 2013 8:02 AM by Christy Rogers

# if/then statements, sorting into categories

If I wrote this:

if [ value] <= 60 then 1

else

if [ value] > 60 then if [ value] < 160 then 2

else

3

end

end

Does "then 1" mean that you add one to something.  In my data i have ~20 values/minute (w/ diff time stamps hh:mm:ss) If the sum for the values for the minute is less than, say, 60 then I want to give myself 1 point for that minute.  Should I put SUM(value) or just [value]?  If the sum for the values is between 60-160 then I want 2 points for that minute.  And if the sum for the values for the minute is above 160 then I want 3 points for that minute.   So in a day there are X minutes and each of those minutes I get either 1, 2, or 3 points. Then add the total for the score for the day.   Is that the code that I wrote above? maybe partially... I'm pretty sure it's not complete.

-Christy

• ###### 1. Re: if/then statements, sorting into categories

Hi Christy,

Change the calculation to look similar to the following:

if sum([value])<=60 then 1

elseif sum([Value])>60 and sum([Value])<160 then 2

else 3

end

Then, you can add a window_sum to the calculation to find the total.

Hope this helps!

-Tracy

• ###### 2. Re: if/then statements, sorting into categories

I put the code in calculation 1.  Thank you!!  I can see by the graph that it sorted the numbers correctly into 3 bins and graphed either a 1, 2, or 3.  so then i should make a new calculation field to add those up?:

WINDOW_SUM([Calculation1] )

• ###### 3. Re: if/then statements, sorting into categories

can I use grand totals instead to get the total points (sum of all the 1s 2s and 3s?)