Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
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
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
@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.
R is really slow with loops for my purpose, and I don't know Python so hence the predicament.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!