cancel
Showing results for 
Search instead for 
Did you mean: 
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 I
Advocate I

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
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors