4 Replies Latest reply on Sep 27, 2013 3:07 PM by Matt Lutton

    Creating Custom BINS

    Kito Patterson



      I'm trying to simply group a metric into custom bins. For example, I want to group all visits that equal 0 in the "0" bucket.............then all visits between 1 and 5 in the "1" bucket..................then all visits between 6 and 10 in the "10" and so on and so forth. It seems simple, but i was wondering should I handle this through a calculated field using Case statements or should I use the BIN feature.




        • 1. Re: Creating Custom BINS
          Matt Lutton

          I believe you'll want to use a Calculated Field, as bins need to be the same # of values in each bin, I believe--and since you want to have a category for "0", I'm not sure a Bin will allow that.


          I'd just do omething like:

          IF sum(Visits)=0 THEN "0"

          ELSEIF sum(Visits)<6 THEN "1"

          ELSEIF sum(Visits)<11 THEN "10"

          etc, etc



          Also, you'll want to move this thread into the "Forums" section to get the best possible response.  By default, threads don't go there, so this happens often!

          1 of 1 people found this helpful
          • 2. Re: Creating Custom BINS
            Kito Patterson

            Thanks Matt for the quick response. I'll make sure to post all subsequent questions in the forum moving forward.

            • 3. Re: Creating Custom BINS
              Kito Patterson

              I tried the below, but I keep getting an error that reads "Expected END to match IF at character 0" from the formula below:


              IF sum([Visits]) = 0 then "0"

              ESLEIF sum([Visits]) between 1 and 6 then "5"

              ESLEIF sum([Visits]) between 6 and 10 then "10"

              ESLEIF sum([Visits]) between 11 and 20 then "20"

              ESLEIF sum([Visits]) between 21 and 30 then "30"

              ESLEIF sum([Visits]) between 31 and 40 then "40"

              ESLEIF sum([Visits]) between 41 and 50 then "50"

              ESLEIF sum([Visits]) between 51 and 100 then "100"

              ESLEIF sum([Visits]) > 100 then ">100"

              ELSE "-1"


              • 4. Re: Creating Custom BINS
                Matt Lutton

                Well, first you've misspelled ELSE in several places. This would need to be:


                IF sum([Visits]) = 0 then "0"

                ELSEIF sum([Visits])< 6 then "5"

                ELSEIF sum([Visits]) < 11 then "10"

                ELSEIF sum([Visits]) < 21 then "20"

                ELSEIF sum([Visits]) < 31 then  "30"

                ELSEIF sum([Visits])  < 41 then "40"

                ELSEIF sum([Visits]) < 51 then"50"

                ELSEIF sum([Visits])  < 101 then "100"

                ELSEIF sum([Visits]) >= 101 then ">=101"

                ELSE "-1"



                No need for the "betweens", since IF-ELSE statements operate in order, and are mutually exclusive, you can condense.  I believe the above should work.