Reply
Frequent Visitor
Posts: 7
Registered: ‎11-04-2018

SELECTEDVALUE doesn't work in a measure table

I encounter a issue that when I use the SELECTEDVALUE function in a normal data table, it works fine.

But when I use the SELECTEDVALUE function in a table which was created by DAX  formula, it can't work anymore.

It's why? Can anyone help me ?

Super User
Posts: 1,627
Registered: ‎07-03-2015

Re: SELECTEDVALUE doesn't work in a measure table

Interesting. Are you trying to use a calculated column?  If so, you shouldn’t need SELECTEDVALUE if you are referring to a row in the table itself. 

* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Frequent Visitor
Posts: 7
Registered: ‎11-04-2018

Re: SELECTEDVALUE doesn't work in a measure table

Yes, it's quite interesting, and you can have a try. I don't know how to share my pbix file, or I can share it to you.
In the new table created by DAX formula, all the columns  are caclulated.
The SELECTEDVALUE is necessary, the value is from a slicer of which the options are defined by myself. I must use the slicer to deal with different cases.

Super User
Posts: 1,627
Registered: ‎07-03-2015

Re: SELECTEDVALUE doesn't work in a measure table

You can’t refer to a slicer in a dax formula for a calculated table. 

* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Frequent Visitor
Posts: 7
Registered: ‎11-04-2018

Re: SELECTEDVALUE doesn't work in a measure table


@MattAllington wrote:

You can’t refer to a slicer in a dax formula for a calculated table. 


Hi MattAllington,

Why can't refer to a slicer for a calculated table?  Is this a bug of Power BI? 

Super User
Posts: 1,627
Registered: ‎07-03-2015

Re: SELECTEDVALUE doesn't work in a measure table

No it is not a bug. Tables and columns are considers static parts of he data model and do not update based on slicer interaction. 

* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Frequent Visitor
Posts: 7
Registered: ‎11-04-2018

Re: SELECTEDVALUE doesn't work in a measure table

Hi MattAllington,
Thank you for your reply.
There is a mistake in my previous description. The real issue is that the SELECTEDVALUE can't work in IF function, the return value of it always is the default.


My SELECTEDVALUE formula is as following: 

        tempVal = SELECTEDVALUE(t_stream_type[type], "Cloud")


And the IF formula is as following:
        multiplier = IF([tempVal] ="Cloud", 1, 2)

And the slicer 'Stream' has three options as the following picture:
pbi_q1.JPG

The issue is no mater what I selected in the slicer, the value of multiplier always equal to '1'.
Could you help me ?


Highlighted
Super User
Posts: 1,627
Registered: ‎07-03-2015

Re: SELECTEDVALUE doesn't work in a measure table

How does the column t_stream_type[type] relate to the slicers in your image. It is not clear. 

* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Frequent Visitor
Posts: 7
Registered: ‎11-04-2018

Re: SELECTEDVALUE doesn't work in a measure table

And now I use the same formula as  multiplier to create a new measure multiplier2 in a normal data table( not calculated table) , the formula is as following:
multipler2 = IF([tempVal] = "Cloud", 1, 2)

 

then multiper2 works well. It's why?

 

pbi_q2.JPG

Frequent Visitor
Posts: 7
Registered: ‎11-04-2018

Re: SELECTEDVALUE doesn't work in a measure table


@MattAllington wrote:

How does the column t_stream_type[type] relate to the slicers in your image. It is not clear. 


Just create a new slicer, and the the 'type' field of t_stream_type to the slicer.