1 Reply Latest reply on Jun 2, 2015 10:31 AM by Joshua Milligan

    Percentage of a column's data that has a value

    guy.raven

      Hi, I'm sure this is really easy and probably been asked before, but I just cant figure it out/find an answer. (I'm a Tableau noob)

       

      I have a column of data, say something like below:

       

      No.Buy
      1Yes
      2
      3Yes
      4Yes

       

      I want to add a column in my text table to say what percentage of the total rows has a "Yes" in it, i.e for the above data it would calculate 75%

       

      Thanks very much

        • 1. Re: Percentage of a column's data that has a value
          Joshua Milligan

          Guy,

          Welcome to the forums!

           

          How about something like:

           

          WINDOW_SUM(SUM( IF Buy == "Yes" THEN 1 ELSE 0 END)) / WINDOW_SUM(SUM(1))

           

          The IF...END statement is operating per Row and just adding a 1 when there is a "Yes".  Those are then aggregated using the SUM and then all added together by the WINDOW_SUM from the numerator.

           

          The denominator is just the WINDOW_SUM of a SUM(1) for each No.

           

          Hope that helps!

           

          Regards,

          Joshua