Reputation: 53
What do you guys think why does not work the following code if I give dynamic value for a slicer which used as a VAR in a calculated table measure?
UPDATE: The calculation works with hard coded index (like 1.151) but doesn't if using a slicer and a dynamic measure SelectedPowerIndex = (SELECTEDVALUE(powerIndexes[pt_index]).
I've created a calculated table in 2 two steps. The code example is only a short filtering producing the same problem.
The calculated table shortly (1) CALCULATETABLE( SELECTCOLUMNS( using selected_index variable at the end, (2) GROUPBY( using X row aggregation from the table created in step 1.
The result is a 3 column table showing as many grouped row as the index gives. Index is for example 1.151, which works if hard coded, not works if dynamic.
If I use slicer of a dimension-table (powerIndexes) to select 1.151, the calculated table is not shown. The slicer is okay, it shows 1.151 in a card if slicer is choosen.
SHORT EXAMPLE CODE PRODUCING THE SAME PROBLEM The second one gives nothing back however 16 rows data in the table with 1.151.
thisWorks=
VAR filtered_table =
FILTER(
globalDatas,
globalDatas[pt_index] = 1.151
)
RETURN filtered_table
thisNotWorks= =
VAR selected_index = [SelectedPowerIndex]
VAR filtered_table =
FILTER(
globalDatas,
globalDatas[pt_index] = selected_index
)
RETURN filtered_table
I used SelectedPowerIndex = SELECTEDVALUE(powerIndexes[pt_index]) The powerIndexes is a one-column table created in Power Query from pt_index column of globalDatas table and there is a one-to-many relation in Power BI between powerIndexes and globalDatas.
It should work fine. The code is a calculated table but I rewrote it with a normal FILTER function resulting the same nothing.
Upvotes: 1
Views: 379
Reputation: 30244
Calculated tables do not work with slicers. Calculated tables are computed at refresh time.
Upvotes: 1