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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ACraig08
Helper I
Helper I

R script not showing result when using an if statement

I am using the R visual ACraig08_2-1706651201092.pngto provide my outputs from my t-test. I used the following code to print out the results (it might look different because I had to use Notepad++ to change the variable names for privacy reasons):

ACraig08_0-1706650675122.png

It prints out the results just fine except that the results of the if statement don't show up. 

ACraig08_1-1706650920457.png

The statements run fine when I test them in R. Any help is greatly appriciated.

1 ACCEPTED SOLUTION
ACraig08
Helper I
Helper I

I figured it out! because I was using cat() it wasn't storing the results in my variable! I changed it to use paste() and it worked just fine!

View solution in original post

3 REPLIES 3
ACraig08
Helper I
Helper I

I figured it out! because I was using cat() it wasn't storing the results in my variable! I changed it to use paste() and it worked just fine!

v-heq-msft
Community Support
Community Support

Hi @ACraig08 ,
Based on your description and the provided code screenshot, please check the syntax of the if statement and the code block within it for any errors and make sure that the condition in the if statement is met. If the condition is not met, the code in the if block will not be executed. If you want to output the result, make sure there is a print or return statement in the if block to output the result. In the context of the R visual object in Power BI, a data frame should be created that will be returned as output. You can also run the same script in an interactive R session outside of Power BI (e.g. RStudio) to see if it produces the expected output. Finally, make sure that your R language package is ready to run in power bi
Learn which R packages are supported - Power BI | Microsoft Learn
Use R in Power Query Editor - Power BI | Microsoft Learn

Best regards

Albert He

 

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



lbendlin
Super User
Super User

I am surprised it works at all. Usually they will not allow you to use any renderer apart from matplotlib.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.