BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Creating calculated columns in tabular models is deceptively similar to creating formulae in Excel. Deceptively, because the underlying language (DAX) is completely different, and you can make use of functions like SWITCH which have no Excel equivalent. This blog shows what calculated columns are, and how to create them.
- Calculated columns
- Using the function wizard (this blog)
- Making choices (the IF and the SWITCH functions)
Posted by Andy Brown on 05 January 2016
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Using the function wizard
Suppose that you want to be able to aggregate transaction volumes by the year in which they occur:
We'll create a column to show the month corresponding to any particular date.
Note that this is actually a bad idea, as it would be much better to do this using a calendar, but a) we haven't covered them in this blog yet and b) this would ruin a nice simple example!
To start with, click on the function wizard tool:
Click on the tool shown here.
To help you choose the right function, choose a category (it's usually pretty obvious what this should be):
Choose this category to find a function giving the year for any given date.
Find the function you want, and double-click on it:
Often it isn't as obvious as this!
SSAS Tabular puts the function name in your formula:
You can now complete the formula by choosing the PosDate field:
Here's the final formula you should get:
I've renamed the column too.
For the final part of this blog, I'll show how you can make choices using the IF or the SWITCH functions.