Forum Discussion

jaryszek's avatar
jaryszek
Super User
1 year ago
Solved

Adding R code bug

hi Guys,

I am getting:


after implementing this R code:


why ? what is happening with my bpip project file?

 full error details:
https://sharetext.io/75f510ff 

Best,
Jacek

 



  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi jaryszek,

     

    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    Please find below documentation link to get data from R script

    Run R scripts in Power BI Desktop - Power BI | Microsoft Learn

     

    Try this code:

    env_value <- Sys.getenv('COSTMGMT_CONFIG_SOURCE_PATH')
    df <- data.frame(Path = env_value)
    df

     

    If this information was helpful, kindly mark the response as accepted and give it a thumbs-up, so it may assist others as well.

     

    Best regards,
    Prasanna Kumar

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jaryszek,

     

    Thank you for reaching out to the Microsoft Fabric Forum Community.


    The issue arises because R script code was manually inserted into the .tmld file of your Power BI Project (PBIP), which is not the correct or supported way to integrate R in Power BI. This causes the error "Multiple SaveChanges without transaction" due to inconsistent or invalid metadata edits. To resolve the issue, remove the manually added R.Execute code from the .tmld file, and instead add your R script using the “Get Data > R Script” option within Power BI Desktop. This ensures that Power BI handles the metadata and transactional integrity correctly. If the project remains corrupted, revert to a previous working version of the PBIP project.


    If this information was helpful, kindly mark the response as accepted and give it a thumbs-up so it can assist others as well.

     

    Best regards,
    Prasanna Kumar

    • jaryszek's avatar
      jaryszek
      Super User

      What should be a format for my query then?

      Source = R.Execute(
      "env_value <- Sys.getenv('COSTMGMT_CONFIG_SOURCE_PATH')
      df <- data.frame(Path = env_value)
      output <- list(df = df)",
      null
      ),
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jaryszek,

     

    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    Please find below documentation link to get data from R script

    Run R scripts in Power BI Desktop - Power BI | Microsoft Learn

     

    Try this code:

    env_value <- Sys.getenv('COSTMGMT_CONFIG_SOURCE_PATH')
    df <- data.frame(Path = env_value)
    df

     

    If this information was helpful, kindly mark the response as accepted and give it a thumbs-up, so it may assist others as well.

     

    Best regards,
    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jaryszek,

     

    Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

     

    Best regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jaryszek,

     

    We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.

     

    Warm regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jaryszek,


    Just a gentle reminder has your issue been resolved? If so, feel free to share the solution that worked for you, or let us know if you found a different fix.

    This helps close the loop on your query and supports others in the community who might face similar challenges.

    Thank you for your time and feedback!

    Best regards,
    Prasanna Kumar