2

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!

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, how to build a calculated table referencing a slicer value even a temporary one in a variable?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.