Forum Discussion
FILTER vs CALCULATETABLE based on Boolean Expression
- Anonymous5 years ago
That's because the second argument to FILTER must ALWAYS be a logical condition (or castable to it) that operates for each row of the table in the first argument (FILTER is an iterator) and all CALCULATETABLE's arguments must ALWAYS be tables. DATESBETWEEN returns a table.
Even the seemingly logical condition in:
calculatetable( A, T[Col] = Value )
is internally translated into:
calculatetable( A, Filter( All(T[Col]), T[Col] = Value ).
So the "logicals" under CALCULATETABLE are just syntactic sugar.
- Anonymous5 years ago
If you read the ultimate source of knowledge on DAX, which is The Book, you'll find the explanation of the use of the seemingly "logical expressions" under CALCULATETABLE that I gave you. No, what the docs mention is syntactic sugar. Only.
Check this out: How CALCULATE works in DAX - SQLBI
Well, Microsoft is just not telling you the whole truth but The Italians do.
Anonymous You mentioned that "CALCULATETABLE's arguments must ALWAYS be tables"
Before posting this question, I checked the MS docs, and what I noticed there was the following:-
1) That CALCULATETABLE does allow boolean expressions- it can be either boolean or table expression
2) Boolean expressions must not use a function that returns a table
I am highlighting these points in green
Now, coming back to my question. Because of these 2 points above (which seem cotradictory to your point that they should always be tables, pardon my ignore) I wanted to try and use the boolean expression using IN as used in FILTER in CALCULATETABLE too
And here's another explanation from Alberto Ferrari himself: Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT - SQLBI