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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Sebas2905
Frequent Visitor

Error using R script transforming data

Hi 

 

I want to use R in Power Query to create a HMAC-SHA1 signature in Power Query. The R-Script I want to run is the following:


library(httr)

key <- "Key"
string <- "String"

signature <- sha1_hash(key, string, method = "HMAC-SHA1")

 

This script works perfectly in RStudio. To use it in Power Query I created a table with a Key column and a String column by using Enter Data. I want the R script to create a signature for every combination of Key and String on every row. The table I created is this:

Knipsel.PNG

 

To run the script I added the step Run R script1 and added the following R script:

 

# 'dataset' holds the input data for this script

library(httr)


key <- dataset$"Key"
string <- dataset$"String"

signature <- sha1_hash(key, string, method = "HMAC-SHA1")

output <- dataset

output$signature <- signature

 

This results in the following error:

 

DataSource.Error: ADO.NET: R script error.
Error in rawstringhash(x, "sha1", key) :
Argument 'x' must be raw or character vector.
Calls: sha1_hash -> <Anonymous> -> rawstringhash
Execution halted

Details:
DataSourceKind=R
DataSourcePath=R
Message=R script error.
Error in rawstringhash(x, "sha1", key) :
Argument 'x' must be raw or character vector.
Calls: sha1_hash -> <Anonymous> -> rawstringhash
Execution halted

ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException

 

Does anyone know why this script won't run? If I replace the parameters key and string with plain text the script works fine, but doesn't calculate the signature per row. So it doesn't recognize my rows as valid parameters in the R script.

 

# 'dataset' holds the input data for this script

library(httr)


key <- "Key"
string <- "String"

signature <- sha1_hash(key, string, method = "HMAC-SHA1")

output <- dataset

output$signature <- signature

 

Knipsel1.PNG

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Sebas2905 

Check if changing dataset$column1 to as.character(dataset$column1) would work.

 

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
michaelsh
Kudo Kingpin
Kudo Kingpin

@Sebas2905  @v-juanli-msft 

Do you know if it (R script) will work in the service...?

@michaelsh 

 

it works if you use a gateway (enterprise or personal) with R installed on it. 

best regards, Sebastiaan

v-juanli-msft
Community Support
Community Support

Hi @Sebas2905 

Check if changing dataset$column1 to as.character(dataset$column1) would work.

 

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

It works! Thanks.

 

Best regards,

 

Sebastiaan

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.