Reputation:
I have a calculated table with an expression like:
Table =
VAR MyVar = {1;2;3}
...
RETURN
SELECTCOLUMNS(...)
This returns a table with a single column. The rows depend on the list defined manually in MyVar
.
I'd like to pass the values of a slicer selection to that list.
Is this possible to do in Power BI Desktop? How?
Thanks in advance!
Upvotes: 2
Views: 4317
Reputation: 40204
Calculated table and calculated columns cannot reference slicer values as they are computed only at the time the data tables are loaded (before any of the visuals like slicers are calculated).
You can have calculated tables that reference slicer selections if they are only created as temporary tables inside of a measure definition, but you can't see them in the Data View like the output of your queries since they are only evaluated within a measure.
Edit:
Within a measure, you could do write something like this:
CountOnDate =
VAR SelectedDate = SELECTEDVALUE(Dates[Date])
VAR CalculatedTable = CALCULATETABLE([...], Table1[Date] = SelectedDate)
RETURN COUNTROWS(CalculatedTable)
A measure can use locally calculated tables during evaluation, but needs to return a single value at the end.
Upvotes: 2