I have created this table in Power BI:
DimProduct = UNION(
ROW("ProductId", 1, "Product", "AB","ProductType","A"),
ROW("ProductId", 2, "Product", "AC","ProductType","A"),
ROW("ProductId", 3, "Product", "AD","ProductType","A"),
ROW("ProductId", 4, "Product", "BB","ProductType","B"),
ROW("ProductId", 5, "Product", "BC","ProductType","B")
)
Then I created this table:
DimProductSelectedType =
VAR vSelectedProduct=
SELECTEDVALUE('DimProduct'[Product])
RETURN
ROW("Col1",vSelectedProduct)
I dropped DimProduct[Product]
into a slicer
I dropped DimProductSelectedType
into a list
I expect that when I pick one product from the product slicer, it will appear in the list. But the list always remains blank.
I had thought that SELECTEDVALUE would reflect any single value picked in a slicer
That's my immediate problem, and this can be summarized as
Table columns that use DAX calcs are evaluated at import time. Measure are evaluated at runtime
What I'm actually working towards is:
- Pick a product in a slicer
- Identify that products product type
- Show visualisations comparing selected product compared to all other products within that product type
I actually started with this and now I'm working my way back.
DimProductTypeSelected =
VAR vSelectedProduct=
SELECTEDVALUE('DimProduct'[Product])
VAR vSelectedProductType=
SUMMARIZE(
FILTER(
ALLSELECTED(DimProduct),
DimProduct[Product]=vSelectedProduct
),
DimProduct[ProductType]
)
RETURN
FILTER(
ALLSELECTED(DimProduct),
DimProduct[ProductType]=vSelectedProductType
)