Type conversions

We will begin with type conversions because you cannot create properly functioning calculated fields without having the fields in the right format. For instance, aggregations work on numeric fields, string functions work on strings, and date functions work on dates. Tableau Public automatically identifies the type of field based on its contents, but this may not meet your needs to aggregate or create calculations. Publicly available data sources, such as the ones available at http://public.tableau.com/s/resources, often have issues with either the format or the quality of the data. This will make it necessary for you to convert fields into different types, and it is quite likely that you will need to strip bad data and identify replacement values as well.

If you are familiar with relational database management, you are probably aware that there are many different field types, some of which are used to govern the field length within a database. Tableau Public focuses on the three primary field types, namely; string, which can be anything; numeric fields, which include integers and float fields; and datetime fields; which include the DATETIME, DATE, and TIME field formats.

You can convert a field to another type by creating a calculated field and wrapping it in the appropriate function. In case fields are of the same parent form or are interchangeable, you can right-click on the field name, select Change Data Type, and then choose the appropriate type. If you do need to change the format manually, you can use the following functions:

  • DATE: This converts the strings that you specify (whether you enter them yourself or they are predefined) into date fields, which can then be used to drill through hierarchies.
  • DATETIME: This converts a field or string into a datetime field, which is a date plus a timestamp.
  • FLOAT: This converts integers into decimal numbers. This function works only on numeric formats.
  • INT: This takes the whole number of a numeric expression by rounding up to the nearest whole number.
  • MAKEDATE: This formats an entry for a year, month, and day into the MM/DD/YYYY format as a proper date. It also accepts fields for the datepart variables.
  • MAKEDATETIME and MAKETIME: These functions accept proper dateparts, just like MAKEDATE, to convert variable or hard-coded sequences into the appropriate field types.
  • STR: This turns a sequence of characters, numbers, letters, or special characters into strings.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset