cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hawk_Wang Frequent Visitor
Frequent Visitor

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 ?

11 REPLIES 11
Super User
Super User

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.
Hawk_Wang Frequent Visitor
Frequent Visitor

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
Super User

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.
Hawk_Wang Frequent Visitor
Frequent Visitor

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
Super User

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.
Hawk_Wang Frequent Visitor
Frequent Visitor

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
Super User

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.
Hawk_Wang Frequent Visitor
Frequent Visitor

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

Hawk_Wang Frequent Visitor
Frequent Visitor

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.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 6 members 1,520 guests
Please welcome our newest community members: