4 Replies Latest reply on Jul 3, 2013 11:40 AM by Justin Smith

    help with calculation fields and syntax?

    Christy Rogers

      I want to assign points (basically multipliers) based on 3 categories (easy, med, hard) .  Currently i have more than one data point /minute so I summed them.  Now I have SUM(value)/minute graphed.

      I would like to make a new graph with my RawScore.

       

      I would like to implement something like this:

      note ** i have a sum(values) for each minute now and basically want to put the point for each minute into 3 bins, multiply by 1, 2 or 3 and add them up.

       

      IF SUM(values) <= 60:

           THEN  **put in EasyPoints Bin** (the Then command is what I don't know how to type in...)

      IF SUM(values) >60 AND <160:

           THEN *add to Medium Points

      IF SUM(values) > 160:

           THEN add to hardpoints

       

      Easyscore = easypoints

      medscore = mediumpoints*2

      hardscore = hardpoints*3

      Rawscore = easyscore + medscore + hardscore

       

      Can I do this all in one field?  Should I make parameters for easyscore, etc?

        • 1. Re: help with calculation fields and syntax?
          Justin Smith

          Christy,

           

          Is it possible to post a .twbx file with the data and maybe an example of what the raw score should be for one of your calculations? It will probably be over my head, but when one of the greats see it, they should be able to help. I'll try though!

           

          Justin

          • 2. Re: Re: help with calculation fields and syntax?
            Justin Smith

            I may have gotten confused on what level you are wanting the raw score. However, the formula I used for Raw Score in the screen shot is:

             

            if [values] <= 60 then [values]

                else

             

                    if [values] > 60 then if [values] < 160 then [values] * 2

                  

                    else

                        [values] * 3

                      

                    end

                    end

              

            end

             

            That may help on the syntax question or at least be a stepping stone in the right direction if you can't post what you are working with. You will need to replace "[values]" with your field that contains "sum([values])" Let me know if I"m totally off the mark or at least helpful.

             

            Justin

            • 3. Re: help with calculation fields and syntax?
              Christy Rogers

              Thank you so much for your help!

              What is the difference between what you put and 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.  I think what I actually want is that (I asked the wrong question).  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.  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.

               

              I really appreciate your help.

              -Christy

              • 4. Re: Re: help with calculation fields and syntax?
                Justin Smith

                Christy,

                 

                Your explanation helps me to make sense of it more. The "then 1" will assign a 1 to each [value] that meets that criteria. You can then total them for the raw score as I understand your need.

                 

                The formula I wrote does not apply now that I understand your question better, although it appears to have helped you with the syntax at least some. Your formula is only missing an "end" for the first if statement.

                 

                See the attached .twbx to see if this is similar to what you have and need.

                 

                Justin