12 Replies Latest reply on Sep 22, 2016 1:09 PM by David Li

    Creating a histogram for counts of correct responses

    Matt Hong

      I have data that is like this:

       

      User ID     | Survey ID          | Question type             | Correct

      23414       | A                  | 1                         | True

      23414       | A                  | 2                         | True

      23414       | B                  | 1                         | False

      23414       | B                  | 2                         | True

      28994       | A                  | 1                         | True

      28994       | A                  | 2                         | True

      28994       | B                  | 1                         | False

      28994       | B                  | 2                         | False

       

      ...etc.

       

      I am looking to create four histograms. Each histogram counts number of users, where each count corresponds to a range in the number of 'correct' responses:

      Screenshot 2016-09-21 13.24.40.png

      Four of these histograms are laid out vertically so that the rows are partitioned into Survey ID, then Question type:

       

      Tableau worksheet mock-up

      Survey     QType                    Histogram

      A               1                  (Chart goes here)

                       2                         (and here)

      B               1                              (Yay)

                        2                         (That's it)

       

       

      To create the field "# correct responses', I have a calculated field whose formula is:

      SUM(if [Correct] then [Number of Records] end)

       

      ...but I can't create bins out of such a calculation. So I added an LOD:

      {FIXED [User ID]: SUM(if [Correct] then [Number of Records] end)}

       

      But then the details from 'Survey' and 'Question type' are left out, i.e. all four histograms look the same because they are each totaling up the # of correct responses across all surveys and all questions.

       

      Two questions:

      1. Why can't I create bins out of the first calculation? SUM(if [Correct] then [Number of Records] end)

      2. What should replace the FIXED level-of-detail calculation so that each histogram is relative to a survey and a question type?