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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CheesePlease
Frequent Visitor

Passing selection to R visual

I want to know the value of a selection made in a table, so I can use this in an R script visual.

 

The end result I'm looking for is to recreate "Highlight" rather than filter. My thinking is that when a user selects a name, I can pass that name to the "col" variable in ggplot, to highlight that data amongst everything else rather than filter to only show that data.

 

I've played around with SELECTEDVALUE but can't get the logic right. Any ideas?

3 REPLIES 3
ELW
Advocate II
Advocate II

I'm interested in this exact topic - were you able to find a solution @CheesePlease ?

TomMartens
Super User
Super User

Hey @CheesePlease ,

 

unfortunately I don't really understand what you mean by highlight instead of filtering (I'm aware of the functional differenced inside Power BI) and passing selections made to the R script visual.

 

For this I just can provide a some general guidance, but maybe you already know that as well. The values well of the R script visual passes a table to the R script, this means that just one parameter will be passed to the R script - this parameter will be a data.frame. Basically this table needs to contain all the information to "draw" your visual. I often use measures to combine multiple selections from slicers using the DAX function CONCATENATEX(...). And decompose the string inside the R script.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens,

 

Thanks for your help.

 

So assume I have data like this:

personxdataydata

Tom

23
Ben52
Bob34

 

On a "person" table visual, I select Ben. I can get this so that it filters the R visual to only show Ben data, but what I want is to feed to the visual that Ben has been selected, so that I can highlight him in a scatterplot, while keeping the other data.

 

In this example I've added a third column called "selected" with values F, T, F. I want PowerBi to do something like this automatically when a user clicks on Ben.

 

 

dataset = data.frame(person = c("Tom", "Ben", "Bob"),
                  xdata = c(2,5,3),
                  ydata = c(3,2,4),
                  selected = c(F, T, F))  

ggplot(dataset) +
  geom_point(aes(x = xdata, y = ydata, col = selected))

 

 example.PNG

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.