Forum Discussion
Expressions that yield variant data-type cannot be used to define calculated columns.
No idea why you get this error but there MUST be a good reason for this.
But the error really is irrelevant. What you're doing with your monster formulas is not the way to handle this. Instead, you should create a proper Date table in your model first of all. You could connect it to the date field in your fact table or leave it disconnected (and most likely hidden). That depends on some other conditions but 95% of the time you should connect it and leave visible to enable slicing by time. In the date table you should have a column that tells you which quarter a date is in and the quarters should be numbered consecutively with integers (this field will be hidden). So, you should have a column holding strings 2018-Q1, 2018-Q2,... and a column that numbers them 1, 2, 3... Once this is in place, it's easy to tell if a date in your fact table falls into the 4-quarter window you want. Say your max date in the fact table is D and it's in quarter Q. Say you have a date D1. Just check if D1 is in one of the quarters Q-1, Q-2, Q-3, Q-4 (Q is the integer I mention above). I'd suggest to put the field (as well as others of this type - you get the idea) in the Date table, not in the fact table. Then slicing will be easy and the model will be as small as possible, your DAX will be simple. Please note that adding columns to slice by to dimensions is the preferred option. ALWAYS.
Please read about what a proper Date table is in a tabular model and why it's so vital to everything you do. This will save you a lot of frustration and head-scratching down the line. Also, for the time-intel functions to work properly you need a Date table.
Also, please bear in mind that if your DAX becomes complex and hard to understand... it's a sign your model is incorrect.
Best
Darek