Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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:
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
Solved! Go to Solution.
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.
Do you know if it (R script) will work in the service...?
it works if you use a gateway (enterprise or personal) with R installed on it.
best regards, Sebastiaan
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
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
41 | |
21 | |
20 | |
20 | |
13 |
User | Count |
---|---|
67 | |
54 | |
42 | |
28 | |
22 |