1 Reply Latest reply on Aug 12, 2016 3:11 AM by Steve Taylor

    How to Count the number of observations of a calculated field

    farzad kargaran

      Hello Tableau folks!

       

      I am having difficulty with one of my dashboards! I really hope that you can help me here! here is the situation:

       

      I am trying to create a dashboard which shows the usage of one of our products.

      In my dashboard I want to show the account owners on each row and show a horizontal bar graph for each to show how many of their accounts have zero usage, how many of them used it 1-10 times and how many of them used it more than 10 times.

       

      I am connecting multiple data sources in order to get the information I want. I am getting the account and account owner info from Salesforce and I get the info about the usage from a Postgres database.

       

      the relationship between these 2 data sources is sub Id (this is a key which is shared between Salesforce and Postgres data). I use this Id to match the accounts on Salesforce and from that I find the owner attached to that account. each sub Id on the Postgres database (which contain the usage data) can have multiple Up Id (this is an Id where gets generated each time a customer use the product). Therefore when I count the number of Up Id for each Sub Id I get the usage of that Sub Id which is related to an Account on Salesforce! (hope it make sense!)

       

      Now I am able to calculate all of this and put them in one workbook. This is how my workbook looks like:

       

      Screen Shot 2016-08-11 at 3.03.56 PM.png

       

      Now I do not care about the exact number of time they used the product! I want to break it down to : (0 times) (1-10 times) and (more than 10 times)

      I created a calculated field called Run that counts the number of Up Id:

      COUNTD([Up Id)])

       

      and another calculated field (called Break Down) that breaks it down to: (this calculated field goes into the measures instead of the dimensions!)

       

      IF [Run]==0 THEN    "0 Run"

      ELSEIF [Run]>0 AND [Run]<11   THEN    "1-10 Runs"

      ELSEIF [Run]>10    THEN    ">10 Runs"

      END

       

      Now I want to be able to count the number of accounts that are in each of these break downs! However when I drop the Break Down into the columns and drop the Number of Records into the measure, instead of counting the number of accounts it counts the number of Runs! I really hope that it makes sense!

       

      For example I want a table that shows Alexandre in a row and in front of it says 11 accounts have 0 usage, 1 account has 1-10 usage and 2 account have >10 usage!

       

      I would really appreciate anyone's help!

      Best