cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Invoke Function writtein in R

Hi there

 

I have very basic R script that I want to use to hash a string using SHA-1 and base64 encode 

 

Say that my string is HY8&V5EDJO8NYT9C2011-12-13T00:44:02ZTest123, I can write this in R and it outputs my new hash string

 

a = base64enc::base64encode(digest::digest("HY8&V5EDJO8NYT9C2011-12-13T00:44:02ZTest123", algo = "sha1", raw = T, serialize = F))

 

I want to convert this into function in PowerBI - please could you tell me what I need to do to acheive this?

 

Thank you so much

Ped

 

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

Hi @Anonymous,

 

I haven't found anything about directly invoke function which written in R script, you can try ImkeF's point of view if it works for you.


In addition, you can write a function which use to call the local R script, for example(load local R script and execute it)

 

let
    LoadLocalRScript = (file_path as text) as table =>
let
    Source = Csv.Document(File.Contents(file_path),[Delimiter=#(lf), Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    RScript =  Text.Combine(Source[Column1], "#(lf)"),
    output = R.Execute(RScript)
in
    output 
in
    LoadLocalRScript

 

 

For detial information, you can refer to below link:
Running Local R Scripts in Power BI

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

I haven't found anything about directly invoke function which written in R script, you can try ImkeF's point of view if it works for you.


In addition, you can write a function which use to call the local R script, for example(load local R script and execute it)

 

let
    LoadLocalRScript = (file_path as text) as table =>
let
    Source = Csv.Document(File.Contents(file_path),[Delimiter=#(lf), Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    RScript =  Text.Combine(Source[Column1], "#(lf)"),
    output = R.Execute(RScript)
in
    output 
in
    LoadLocalRScript

 

 

For detial information, you can refer to below link:
Running Local R Scripts in Power BI

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Greg_Deckler
Super User
Super User

In the Query Editor, you should be able to add an R Script step. It is the last icon on the right in the Query Editor.


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition
ImkeF
Super User
Super User

I don't know of any possibility for M to create hash strings.

 

But you can run your R-script in the Query Editor instead: https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-r-in-query-editor/

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

Anonymous
Not applicable

@ImkeF hi there yes thats what I was getting at - if M could somehow "M" an "R" function 🙂 It would be cool actually

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors