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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

rcpp - pull data using SQL query and run loop using c++ commands from rcpp to transform data

As summarized in subject, I'd like to do the following:

- Run SQL query and pull data

- Run c++ loop on this data using Rcpp to transform the data

- Use this data for visualizations, etc

- Refresh data repeats this process

 

Any restrictions/issues? Thanks for clarifying.

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

So, @ImkeF might have a better solution for this but Power BI supports inserting R and Python steps but I am not aware of a way of inserting C++ code with Power Query.

 

https://community.powerbi.com/t5/Community-Blog/The-Languages-of-Power-BI/ba-p/69104



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

As @Greg_Deckler said: Only R or Python are natively supported.

But both will not be folded to the server, so all data from the SQL server has to be pulled and transfered to R before the c++ transformations can begin. Whereas with M or many transformations made with the UI in the query editor, the steps might be folded back to the server. 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

@Greg_Deckler Thanks for your response. I believe Rcpp package is supported by R in Power BI:

https://docs.microsoft.com/en-us/power-bi/service-r-packages-support

 

Rcpp allows C++ code to be used in R itself:

http://adv-r.had.co.nz/Rcpp.html

 

So would it be possible to code a loop using Rccp package and would it run in Power BI service?

 

Thanks for your time again.

You can try it! But then, why not just use R or Python code to execute the loop? Seems overly complicated and prone to fragility.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

R is really slow with loops for my purpose, and I don't know Python so hence the predicament.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.