Since last week’s blog post caused quite a lot of interest, here’s something similar: did you know you can trigger a Flow in Microsoft Flow and get a response from it back using Power Query/Power BI?
To start off, I suggest you read this post by Irina Gorbach which shows how a Flow can be triggered by a call to a REST API. Now consider the following Flow which is similar to the one in that post:
It has a Request trigger:
…a Translate text step as the second step, that takes the text passed in to the Request trigger through the request body and passes it to the Microsoft Translator API where it is translated from English to French:
…and then, finally, returns the translated text back using a Response step:
It’s very easy to call this Flow from Power Query or Power BI. First, create two parameters in the Query Editor: one called TextToTranslate that contains the text you want to translate from English to French (in this case, “What time is it?”)
…and another called FlowURL which is the URL copied from the Request trigger of the Flow
Then all you need to do is to call the Flow using a query that makes a POST request to the Request trigger:
[sourcecode language='text' padlinenumbers='true'] let Source = Web.Contents(FlowURL, [Content=Text.ToBinary(TextToTranslate)]), GetText = Text.FromBinary(Source) in GetText [/sourcecode]
And voilà, your query will pass the text in the TextToTranslate parameter to the Flow and return the translated text:
So basically, in this case I’ve used Flow to create a web service without writing a single line of code. I can see a lot of potential uses for this and I suspect I’ll be blogging about Flow a lot in the future. A word of warning though: do not try to use this as a way of updating a data source. As I mentioned last time, when you run your query you’ll find Power Query/Power BI calls the web service twice. For example, I created a Flow similar to the one above that used the Insert Row step to take text sent to a Request trigger and add it to a table in an Excel workbook, and of course every time I refreshed my query I got two identical rows in my Excel table.
Wow, thank you great combo of Excel / Power BI, Microsoft Flow, Cognitive Service.
I will try this, I will share this
Great…
Reblogged this on MS Excel | Power Pivot | DAX | SSIS |SQL.
Hi,
I’m looking for related samples,
which a table in Excel use flow, which pass some rows, do something in flow, return some rows.
My scenario:
1. Send some nitifications from data in table rows of Excel by Microsoft Flow.
2. Query a Azure SQL Database from data in table rows of Excel by Microsoft Flow.
Regards,
Yoshihiro Kawabata
That sounds possible with Power Query and Flow, but why would you *need* to use Flow in your scenario? Why not just do everything in Power Query?
Hi Chris, i’m looking for a solution for stripping out html tags from a ProjectWebApp multi-line custom field … i was wandering if you know if powerbi have a stripper in the pipeline that can be used natively within powerquery … or one should look at utilizing flow to push a string over to a sql function to achieve this?
Could you use this? https://blog.crossjoin.co.uk/2017/04/25/using-text-betweendelimiters-to-extract-urls-from-a-web-page-in-power-bipower-query-m/