Calculations and Functions

What are calculations and functions and why do we use them in data visualisation software like Tableau?

Calculations

Often for your analysis you may need a field that isn't already in your dataset - but can be easily calculated. For example if you needed a column that stated profit, you can create a calculated field to work this out from your sales and costs columns.

Functions

There are many functions already set within software such as Tableau, Power BI, Alteryx, SQL & Excel which can be used within calculations to perform a given instruction.

There are different set functions depending on the data type - with a range of uses, for example with string data in Tableau:

  • CONTAINS, ENDSWITH, STARTSWITH - Boolean functions which will return a true/false value if a string contains, ends with, or starts with a given argument respectively.
  • Some functions can help when cleaning your string data - for example UPPER, LOWER, PROPER can change whether your string is in all upper case, lower case or put it into title case with a capital at the start of every word.

There are a lot more functions for strings and other data types. On the right hand side of the calculation pop up in Tableau you can search through these functions and find a description of what they do. You can also see how to input the arguments to the function to make it work.

There may be different syntax used for similar functions across different software. Often these can be in similar formats with very subtle changes. For example if using an IF statement in Tableau, you must close the function with ELSE 'X' END, whereas if you are using M in Power BI there is no need to include the END to close the function. There is usually a workaround to be able to do similar things with functions in different software and often there is information on how to do this posted on different forums on the internet.

Author:
Joe O'Connor
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab