563 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Learn how to create calculated columns in a tabular model using DAX
Part two of a three-part series of blogs
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.
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.
|Parts of this blog|
25 Aytoun Street