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
keknight
Frequent Visitor

Overlaying scatter plots with R

Hello, 

 

I'm new to R and new-ish to Power BI, and trying to replicate in Power BI something I have previously created using Python (matplotlib). 

 

I want to pull data from two distinct datasets (they cannot be merged) and visualize them simultaneously in one scatter chart. I have different visualization criteria for each dataset, which is why they must remain separate. 

 

It seems that to do this in Power BI with R, I need to create two data frames using my two distinct data sets. However, I don't see a means to do that within the R Script Editor (the dataframe area is grayed out). My distinct datasets are already in the data tab, one of which was created using the CALCULATETABLE function (not a query). I've searched online for a solution, but can't find what I'm after. 

 

What am I missing? How do I essentially "superimpose" one scatter chart on top of another, even when the plotting criteria is different for each chart?

5 REPLIES 5
keknight
Frequent Visitor

Thanks to those who replied, I appreciate it. I did find a semi-workaround: I backtracked a bit and created a mega-dataframe (for the grayed out #create dataframe area--I just incorporated every single datapoint I wanted on my final graph into one huge dataframe mess), then created some mini dataframes using R within the script editor, applied some filters to these mini dataframes according to what I wanted from each, and then merged these separately filtered dataframes back into one dataframe for the final graph.

 

But if anyone at Microsoft is listening, it would have been much simpler to allow for more than one dataframe from the start.  I'm still not able to get exactly what I want.

Hi @keknight,

 

I would suggest you add it as an idea on Power BI Ideas forum to improve Power BI on this feature. Smiley Happy

 

Regards

BeardyGeorge
Advocate I
Advocate I

It's another workaround, but the RODBC library works in PBI desktop, so you can query databases from within the visual (this also solves the PBI deduplication problem).

 

Unfortunately for reasons best known only to Microsoft you can only create a single dataframe as your source dataset(s).

Anonymous
Not applicable

 

My understanding is that you input into R various dimensions and measures etc. which will form a table and be translated into a dataframe for you to play with in R (the dataset in the grey bit).

 

Apart from this there is no other way of getting data into your R script so if you cannot join your data into one table then you cannot feed two dataframes into R from Power BI.

 

If you want to go particularly rogue (i do not recommend this for any robust processes but as a one of it works), you could send your first dataset into R. And for your second datset, create a table (visual) in Power BI of your data, export it as a csv to your desktop and then in your R script in power BI you can read.csv() your exported data to bring in your second dataset.

 

Obviously the above is a manual process and really only works as a one off.

 

Alas I can't think of any other way to plot two datasets in power bi at the same time.

 

Hope this helps,

 

Will

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.