4 Replies Latest reply on Mar 15, 2017 4:35 PM by Rob Kime

    Counting records based on a condition Tableau 10

    Rob Kime

      Tableau Community

       

      I am trying to count the number of MSAs that meet the inclusion criteria in sheet 6 based on the input parameter for % of Total Sales.

       

      I have created a T/F condition based on the parameter.

       

      I have tried counting the records that are "T" a number of different ways and can't make this work.

       

      Any suggestions would be greatly appreciated!

       

      Thank you!

       

      Rob

        • 1. Re: Counting records based on a condition Tableau 10
          Michel Caissie

          Rob,

           

          Try this

          WINDOW_COUNT(IF [CF: Inclusion Threshold % of Sales T of F] THEN ATTR( [Msa Name] )ELSE NULL END)

           

          In the attached, I put the result in the Title.

           

          Michel

          1 of 1 people found this helpful
          • 2. Re: Counting records based on a condition Tableau 10
            Rob Kime

            Michel,

             

            That is fantastic.

             

            Thank you!

             

            I am trying to wrap my head around why the Attribute function makes this work.

             

            I was getting error messages about the combination of aggregate and non-aggregate functions. I think what this does is make MSA Name the same level of detail as the calculated field for Inclusion Threshold?. Is that accurate?

             

            A follow up question if you have time.

             

            Say I wanted to use this count in a dashboard. I would normally create a calculated value and put it in text on it's own worksheet and bring that worksheet into the dashboard.

             

            When I try that here I get a zero. I believe that is because the window_count refers to what's in that particular sheet?

             

            Is there a way to do this count so that I can put the value in a separate sheet and have some flexibility to move it around in a dashboard?

             

            Your advice and time is greatly appreciated!

             

            Rob

            • 3. Re: Counting records based on a condition Tableau 10
              Michel Caissie

              WINDOW_COUNT(IF [CF: Inclusion Threshold % of Sales T of F] THEN ATTR( [Msa Name]

               

              Because the condition [CF: Inclusion Threshold % of Sales T of F] is an aggregation (a boolean result computation based on multiple rows) , the THEN statement must be an aggregation of those rows.

              Because you have Msa Name on the Rows in the View,  it means that every Msa Name in the view, correspond to a number of rows in the Dataset which all have the corresponding Msa Name. So you have to aggregate those rows, and the ATTR() function will return the unique Msa Name of those rows.

               

              For the other question, since you need the Msa Name in the view to compute this count, what you can do is duplicate the sheet, put the value in the Title as I did,  bring this extra sheet on the dashboard and display only the Title.

              1 of 1 people found this helpful
              • 4. Re: Counting records based on a condition Tableau 10
                Rob Kime

                Michel

                Got it. Excellent. Thank you again for your time and expertise. Much appreciated!

                 

                Rob