March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I want to create a table containing (independent of the context) all rows of a table, but filtered on a column. A straighforward way is to use FILTER:
MyFilteredTable = FILTER(ALL(MyTable), MyColumn = "MyValue")
My undrstanding is that I could have used CALCULATETABLE with similar results:
MyCalculatedTable = CALCULATETABLE(ALL(MyTable), MyColumn = "MyValue")
However, the resulting table is not filtered, which might be indeed correct if one consider that the filter is applied before the evaluation of ALL(MyTable).
Now using a variable should solve that, as I'm sure it will be evaluated before the CALCULATETABLE
VAR AllMyTable = ALL(MyTable) MyCalculatedTable = CALCULATETABLE(AllMyTable, MyColumn = "MyValue")
That is not the case: MyCalculateTable still return on non-filtered table.
Am I missing anything ?
Note: I want to use CALCULATETABLE because I have actually a set of values to filter on (like VALUES(MyColumn)), which is not supported by FILTER.
Solved! Go to Solution.
The filter portion of calculatetable always gets applied first, then the first parameter. It is not important if the first parameter is a variable or a native formula inside calculatetable in this case. You are first applying a filter and then removing it with all.
Maybe this
calculatetable(mytable,filter(all(mytable),mytable[mycolumn]=“myvalue”))
@TL5866 wrote:Thanks. I was expecting that.
Then how would you suggest to do something like this, which is not supported by FILTER ?
MyFilteredTable = FILTER(ALL(MyTable), VALUES(MyColumn))
MyFilteredTable = calculatetable(mytable,ALL(MyTable), VALUES(MyColumn))
The filter portion of calculatetable always gets applied first, then the first parameter. It is not important if the first parameter is a variable or a native formula inside calculatetable in this case. You are first applying a filter and then removing it with all.
Maybe this
calculatetable(mytable,filter(all(mytable),mytable[mycolumn]=“myvalue”))
Thanks. I was expecting that.
Then how would you suggest to do something like this, which is not supported by FILTER ?
MyFilteredTable = FILTER(ALL(MyTable), VALUES(MyColumn))
@TL5866 wrote:Thanks. I was expecting that.
Then how would you suggest to do something like this, which is not supported by FILTER ?
MyFilteredTable = FILTER(ALL(MyTable), VALUES(MyColumn))
MyFilteredTable = calculatetable(mytable,ALL(MyTable), VALUES(MyColumn))
Aaah, right...
Thanks !!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |