9 Replies Latest reply on Aug 13, 2019 10:36 AM by Eric Renner

    Calculated Field similar to Count if on Dynamic Bar Chart

    Eric Renner



      I am trying to figure out how to do a countif in Tableau Desktop 19.1.6


      Basically I have 4 goods. For simplicity we will call them 1, 2, 3, & 4. I am currently totally them on the date they were produced = CDAT onto a Stacked Barchart. That works great. Problem is a certain percentage break after X number of days before their end of life. I want the bar chart to be able to adjust the totals based on a percentage of "still working" that I can manually enter. I have created a Parameter that displays in Percentage = A Percent Working. I am having a hard time coming up with the calculated field to use. Here is an example data set.


      On 1/1/2000 product 1 was produced 10 times.

      On 1/2/2000 product 2 was produced 8 times.

      On 1/2/2000 product 3 was produced 20 times.


      Over the live span of product 1, 90% will not break and will complete their jobs. Product 2, 3, & 4 all have different percentages.


      I want to be able to input 90% into my parameter (1 Percent Working) and for the totals to adjust to:

      On 1/1/2000 Product 1 = 9 remain

      On 1/2/2000 Product 1 = 7 remain (rounded to whole number from 7.2)

      On 1/3/2000 Product 1 = 18 remain


      This must also work for 2, 3, & 4 on my stacked Bar Chart.


      I've tried the following:


      this works but I only want product 1 not 1,2,3,& 4

      ROUND(COUNT([Cdat])*[1 Percent Working],0)


      this one fails because I am mixing an Aggregate with a non-aggregate...which I don't understand

      IF ([Product])=1 THEN ROUND(COUNT([Cdat])*[1 Percent Working],0) END


      Any help would be appreciated and I'll try to answer any questions that I can. And, my company will not allow me to share data, but I can generate more fake data if needed.





      Edit: added clarification on percentages

      Edit: typos