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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
gradient
New Member

Returning the selected value of a table for all rows of that visual

Hi
I'm finding this particular issue far more challenging than expected and have thus far failed to figure out a solution to what I thought was a relatively simple problem

 

I have a table that has an id and a name

 

I display this is a table visual and wish to create a measure that will display the selected rows id on every row of the visual

 

ID      |      Name      |      Selected ID
1       |   Bob            |       2
2       |   Larry          |       2
3       |   Steve          |       2


In the above example the user has clicked on rwo 2 in the table and so the selected ID produced by a dax measure should return the id of that row for every row

But it's not so simple. Using SELECTEDVALUE does not return the selected row and instead only returns the id of each row so i just end up with the rows own row ID rather that that of the selected row.

Can anyone shed any light on how I can achieve the above, or whether it's simply not possible?


 

3 REPLIES 3
Dangar332
Super User
Super User

Hi, @gradient 

make a new table of id column 

new table =
all(tablename[ID])


and don't connect it with your data model
make a new measure

selected id = 
SELECTEDVALUE('id only'[id])


make table visual

drag your id,name column from your old table and put measure

it look like below

Dangar332_0-1707574752932.pngDangar332_1-1707574772352.png

 

gradient
New Member

That's a really interesting solution, thank you Barritown

I was hoping to be able to get the selected value of a table visual within that same visual, but it seems it's not possible.

Your solution however has inspired an alternative approach to the problem I was trying to solve though, so your help is very much appreciated.

barritown
Super User
Super User

Hi @gradient,

 

Normally, it shouldn't be possible because if you add two similar tables with ID and Name and select some name on one of them you will see that the second table contains only selected entry. So the "greyed out" entries in the first table are invisible.

But here is the way to fake this behaviour (applicable if the number of rows is small enough so you can fit them into one visual without scrolling panes).

You create a full copy of your original table and add two table visuals connected to the different tables to your dashboard.

Then you create such a measure in the second table and add it to the visual connected to the second table:

Measure = IF ( ISFILTERED ( 'Table'[Name] ), MAX ( 'Table'[ID] ), BLANK ( ) )

And two more measures to fake the color scheme (you apply them in the Cell Elements section of the visual for the column with the measure above):

Conditional Color Font = 
VAR primaryCondition = ISFILTERED ( 'Table'[Name] )
VAR currentID = MAX ( 'Table 2'[ID] )
RETURN IF ( primaryCondition && currentID <> [Measure], "#676665", "black")

Conditional Color Background = 
VAR primaryCondition = ISFILTERED ( 'Table'[Name] )
VAR currentID = MAX ( 'Table 2'[ID] )
RETURN IF ( primaryCondition && currentID <> [Measure], "white", "#E5E5E5" )

Then you place the visual connected to the original table (don't forget to make the background transparent) on top of this visual and enjoy the result:

barritown_0-1707436396111.png

I also attach the PBIX file for convenience.

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors