cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TerryR
Level: Powered On

Assign value from SQL table to variable

I am creating a report that updates an excel table to be emailed daily from data in a SQL table.  The report needs to be able to determine which records were added after the previous report and only show those on the new report.  That works well by just deleting the old records and adding the new ones.  I have a separate table that could be used to hold the last record ID from the previuous report.  With that I was hoping to pull only the record ID's greater than the previous day. 

The problem is to get that ID number into a variable that I can use to filter data with.  

The second part of the problem is to update the table with the "new" last record.

 

The other option I tried was to just filter by time, since the report will go out at the same  but that doesn't appear to work in Flow.

1 ACCEPTED SOLUTION

Accepted Solutions
TerryR
Level: Powered On

Re: Assign value from SQL table to variable

I used Compose to pull the value from the array with this formula...

 

"@first(body('Get_Last_Report_rows')?['Value'])?['InspReportLastID']"

 

Then used the output in the formula

     ID gt Output

 

It retrieved the correct number, but when I used the value in the SQL Get Rows filter it did not return all the data that it should.  It only filled in a few rows when it should have about 10.  I had to put a short delay in before the email sent out to allow all the records to actually get into the Excel file.

 

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Assign value from SQL table to variable

 

Hi @TerryR ,

 

I am afraid I can hardly figure out your specific needs only from your description.

Would you please illustrate your needs with screenshots?

Please provide more explanation about your needs.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TerryR
Level: Powered On

Re: Assign value from SQL table to variable

My data is all in SQL and the flow will copy new data to an excel table to be sent out on a schedule. I'll start with the first step I'm having trouble with.

I need to be able to get the ID of the last inspection report from the LastReportKey table.

IndexKey

InspReportLastID

1

568344

 

This value will need to be used in the filter to get new inspection data rows.  How do I get that number into a variable to use in the query of the inspection data table? The filter would be something like this...

 

Filter:  ID gt Max(InspReportLastID)

 

TerryR
Level: Powered On

Re: Assign value from SQL table to variable

I used Compose to pull the value from the array with this formula...

 

"@first(body('Get_Last_Report_rows')?['Value'])?['InspReportLastID']"

 

Then used the output in the formula

     ID gt Output

 

It retrieved the correct number, but when I used the value in the SQL Get Rows filter it did not return all the data that it should.  It only filled in a few rows when it should have about 10.  I had to put a short delay in before the email sent out to allow all the records to actually get into the Excel file.

 

View solution in original post

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

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
Users online (6,141)