Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Hawk_Wang
Regular 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
v-chuncz-msft
Community Support
Community Support

@Hawk_Wang,

 

You may also check Change how visuals interact in a report.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.

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



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.


@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? 

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 an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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

There is not enough information to help you here. You don’t say which table is the calculated table, if the column in the slicer is in that calculated table or another table. If any of these tables are joined and if so which Direction the relationships are etc. All this Information is relevant. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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 ?


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



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.


@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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.