web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Populate Form Fields u...
Power Apps
Answered

Populate Form Fields using Custom SQL Query

(0) ShareShare
ReportReport
Posted on by 13

Hello forum , 

 

I am looking into building a Power App with a form in front. some of the fields in the form are to be populated automatically from the result of a custom sql query. how can I achieve this ?  Can I trigger the query directly from the Power app form ? Do i need to use the Power Automate to bring the data from the Sql server.  We have on-prem sql and the gateway connections in place. 

 

thanks for your help

Categories:
I have the same question (0)
  • timl Profile Picture
    37,212 Super User 2026 Season 1 on at

    Hi @Adhan 

    It's not possible to call the query directly from Power Apps. You'll need to execute the query from a Power Automate flow.

    If it's possible to encapsulate the query in a SQL Server view, you can connect your Power App form directly to the view.

  • Adhan Profile Picture
    13 on at

    Hi timl, Thanks for your response. The second option seems possible.  we can create sql view in the db that is not a problem but the view needs to be filtered to specific value from the field in the form for example customer number field.  can we filter the result sets to the specific customer in context ? 

     

    The first option with Power Automate, will this method increase the cost of the solution as power automate flow will incur cost every time it is run right ?

     

    As a third option, is it possible to use virtual table in data verse to surface result from the sql view?

     

    Apologies for multiple sub questions.  

  • Verified answer
    timl Profile Picture
    37,212 Super User 2026 Season 1 on at

    Hi @Adhan 

    In answer to the first question, yes you can filter a view. Let's say you want to display customer number 1234. To do this, you would set the Item property of your form to this:

    LookUp(YourSQLView,
     CustomerNum=1234
    )

     

    For question 2, SQL Server is a premium connector and requires a premium license. If you were to purchase a Power Apps per user/per app license, this would include Power Automate flows that are called from the app, so there would be no additional cost on top of that.

     

    For the 3rd option, yes it's possible to use a virtual table in Database. It's worth reading about some of the limitations in the documentation, such as the requirement to surface a GUID unique column.

    https://learn.microsoft.com/en-us/power-apps/developer/data-platform/virtual-entities/get-started-ve

     

  • Adhan Profile Picture
    13 on at

    Thanks @timl. you are super star. 

  • timl Profile Picture
    37,212 Super User 2026 Season 1 on at

    Thanks @Adhan glad to help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 474

#1
Valantis Profile Picture

Valantis 474

#3
WarrenBelz Profile Picture

WarrenBelz 375 Most Valuable Professional

Last 30 days Overall leaderboard