cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
BrianHFASPS
Level 8

SQL Get Rows similar to WHERE statement and send as email with excel attachment

I am trying to build a flow that will grab rows from an SQL view. I want to filter it like a query with a WHERE statement like WHERE [Date Field] = '2019-10-31' I can't figure out how to formulate the GetRows for that?

 

Second question, I would like this flow to be triggered from within a PowerApp. The idea is the app will generate the rows, the flow will grab the rows maybe with the filter input from above from app or asking user and then grab those rows and email them to the user in an Excel file.

 

I have looked at guides and templates and not having much luck figuring this out. Any pointers to similar that I could look at and understand would be great. Thanks.

4 REPLIES 4
Dual Super User
Dual Super User

Re: SQL Get Rows similar to WHERE statement and send as email with excel attachment

Hey @BrianHFASPS 

 

For a Get rows action in MS Flow, you can refer to the following doc to get filtered rows using odata filter queries: https://flow.microsoft.com/en-us/blog/advanced-flow-of-the-week-filtering-with-odata/

 

To trigger a flow from powerapp, you can get started here: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/using-logic-flows

 

Note that you can send data from PowerApps to flow in string format and then deserialise in flow. A better option would be to trigger the flow simply from a PowerApps button and in the Flow, add the get rows action and the filter query and then populate the excel with those extracted rows. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

BrianHFASPS
Level 8

Re: SQL Get Rows similar to WHERE statement and send as email with excel attachment

Thanks for the response but I guess I am not understanding the translation of SQL commands to odata commands. I got it to work sort of by switching to SQL Run Query. Here is what I am trying to do.

  1. User presses button in Powerapps.
  2. Powerapps what to file on, like 2019-10 or 2019-11
  3. Flow then takes that response and runs SQL View with filter based upon that entry
  4. Resultant table is inserted into an Excel file (or CSV)
  5. File is then emailed to user.

If I use a SQL Query I don't see anyway to use a variable inserted from Powerapps? Is there anyway to make a temporary Excel in the flow or does it have to save it to OneDrive in process. I really just want to take the SQL response in table form and email it to user. Is that possible? 

Dual Super User
Dual Super User

Re: SQL Get Rows similar to WHERE statement and send as email with excel attachment

Hey @BrianHFASPS 

 

Please take a look at the screenshots below: 

 

ddw1.PNG

 1. You can initialize a variable and get the value for it from Power Apps. and later use that in the query.

ddw2.PNG

 

2. directly request a variable value from PowerApps in the action for the query. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: SQL Get Rows similar to WHERE statement and send as email with excel attachment

Hi @BrianHFASPS ,

 

Have your problem been solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

 

Best Regards,

Alice

 

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,991)