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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Using 2 tables with R

I am using R script within the data transform. I know to refence to refence the curret table, you use "dataset". If there is a way, how would I refence a second data table that I have loaded in powerbi already? 

ie I have a live data table that I am working with and the second table that I need to refence is a updating master name list. So if a name does not show up on the table I am working with then my code notes the name has a zero for my data or if the person is no longer around they don't show up in the report. 

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. I'm not sure I would create a complex transformation and etl with R or Python but yes you can use more than 1 table. You just need to take a look at PowerQuery code to modify the parameters. You can activate "Formula Bar" to check the code. That might help next time. Let's check how it works by default taking one "dataset"

R.Execute( #"Previous Step", [dataset=#"Previous Step"] )

If you want to use another frame there, you can just specify it in the powerquery line like:

R.Execute(#"Previous Step", [dataset=#"Previous Step", dataset2=#"Other Step", dataset3=#"Other Table"])

That way the script you will write latter know more than one frame. You will be able to combine in any way you want. I'm not an R developer, but here you have an example:

df_A <- dataset
df_B <- dataset2
df_C <- dataset3
df_temp <- rbind(df_C, df_B, df_A)
output <- .....

You can read a more detailed answer here: https://stackoverflow.com/questions/44897796/operations-on-multiple-tables-datasets-with-edit-querie...

I hope that helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

View solution in original post

1 REPLY 1
ibarrau
Super User
Super User

Hi. I'm not sure I would create a complex transformation and etl with R or Python but yes you can use more than 1 table. You just need to take a look at PowerQuery code to modify the parameters. You can activate "Formula Bar" to check the code. That might help next time. Let's check how it works by default taking one "dataset"

R.Execute( #"Previous Step", [dataset=#"Previous Step"] )

If you want to use another frame there, you can just specify it in the powerquery line like:

R.Execute(#"Previous Step", [dataset=#"Previous Step", dataset2=#"Other Step", dataset3=#"Other Table"])

That way the script you will write latter know more than one frame. You will be able to combine in any way you want. I'm not an R developer, but here you have an example:

df_A <- dataset
df_B <- dataset2
df_C <- dataset3
df_temp <- rbind(df_C, df_B, df_A)
output <- .....

You can read a more detailed answer here: https://stackoverflow.com/questions/44897796/operations-on-multiple-tables-datasets-with-edit-querie...

I hope that helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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