Forum Discussion
Problems using SELECTEDVALUE in DAX
I am having an issue using selectedvalue function from a slicer.
Table name is RegionTable
Region field contains US, Canada, EMEA, APAC
This table is used as a slicer
I want to assign an attribute in a different table based on the slicer and using DAX
Table name is SalesTable
Numerous fields
OriginatingRegion field exist
DestinationRegion field exist
I would like to add two new columns
OriginitatingRegionFlag = 25 if OriginatingRegion = selectedvalue on RegionTable otherwise OriginitatingRegionFlag = 10
DestinationRegionFlag = 25 if DestinationRegionFlag = selectedvalue on RegionTable otherwise DestinationRegionFlag = 10
For some reason this doesn't work. It seems that DAX does not like selectedvalue in formulas. If I add a column to show selectedvalue it always shows Blank
However, if add a measure for selectedvalues and then add it to a card it shows well
Any asistance is appreciated. I thought this would be simple 😞
arcegabriel In theory something along the lines of:
OriginitatingRegionFlag = IF(MAX('Table'[OriginatingRegion]) = SELECTEDVALUE('Table1'[OriginatingRegion]),25,10) DestinationRegionFlag = IF(MAX('Table'[DestinationRegion]) = SELECTEDVALUE('Table1'[OriginatingRegion]),25,10)
5 Replies
- Greg_DecklerCommunity Champion
arcegabriel Calculated columns are only re-calculated at the time of data refresh and thus are unaffected by dynamic things like user interaction. SELECTEDVALUE is a function meant to be used in measures. You will need to use measures to accomplish what you want to achieve.
- arcegabrielHelper I
Thanks I understand but terribly lost on how to do that with measures.
Appreciate any suggestions or a nudge on the right direction
- ryan_mayuSuper User
could you pls provide the sample data and expected output?
- Greg_DecklerCommunity Champion
arcegabriel In theory something along the lines of:
OriginitatingRegionFlag = IF(MAX('Table'[OriginatingRegion]) = SELECTEDVALUE('Table1'[OriginatingRegion]),25,10) DestinationRegionFlag = IF(MAX('Table'[DestinationRegion]) = SELECTEDVALUE('Table1'[OriginatingRegion]),25,10)- arcegabrielHelper I
Thanks, this worked well for me (had to make some adjustments to align with my model). Appreciate it