1 Reply Latest reply on Feb 29, 2016 4:43 PM by Terri Bly

    How to retain nulls in Web Data Connector data

    David Sutherland


      I'm relatively new to Tableau and even newer to developing connectors, but I adapted the JSON connector example from the Web Data Connector SDK to suit my application.


      I've been testing it using the simulator and in the resulting table, it definitely looks like there are cells that should be null.  Once I import the data using the WDC in Tableau, for all of the numeric measures, Tableau converts all of the nulls to 0. 


      I think for some uses this is a good behavior, but I'm working with a sparse dataset where I want to sum/count over the measures and exclude null values.  If the nulls are converted 0's, they're indistinguishable from data values that happen to be 0.  It would be some work to change the data to be non-zero so I could exclude zero's explicitly, but I can do that if absolutely necessary.


      So I have a few questions:

      - Is it expected behavior for Tableau to convert these numeric measure values from null to 0?

      - If so, there a way to turn this off in the WDC or in Tableau?

      - If no, is there a way to distinguish between the "null 0's" and the "actual 0's"?


      Thanks for your help!

        • 1. Re: How to retain nulls in Web Data Connector data
          Terri Bly

          Hi David,


          JavaScript primitive values null, undefined and NaN are stored as a default value depending on the data type when creating an extract with a web data connector. The default value is zero for float and int data types and an empty string ("") for string data type fields.


          There are two possible workarounds:


          Importing as a string and converting the data type in Tableau is the best way of handling nulls.  This is because non-numeric strings and empty strings convert to nulls when switching the data type to a number as well as the fact that the default value for those JavaScript primitives for string data types is an empty string.


          An alternative workaround would be to check if the returned value is a zero and replace it with a NULL.  This does depend on the base data not actually including any zeros as there is no way to know in Tableau if the value is a zero because it should be NULL, or because it is a zero.


          There is currently no workaround for inserting NULL values for string fields in Tableau.


          Hope this helps!

          Terri B.