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 / Filter data source by ...
Power Apps
Unanswered

Filter data source by ContextVariable

(0) ShareShare
ReportReport
Posted on by 273

This forum has been really helpful, so here's my next question / challange. 

 

I have a screen where the user can select from a list of tasks. The tasks are a vertical Gallery attached to a data source.

I want the user to select a task and then the screen will navigate to a new screen detailing the task. 

 

At the moment I have it so that this funciton works and navigates to the new screen with the title of the screen as the task name (by using a context variable) 

 

2017-03-02 10_44_08-PowerApps.jpg

 

How do I then list all the different details of the task? I can make a data source that will contain all the task data from the SQL Server, but how do I ensure that the data returned is based on the currently selected task? If I was thinking in "SQL" terms it would be 

 

SELECT * FROM dbo.tasks WITH (NOLOCK) where TaskName = "task name" 

 

But I don't know how to set those conditions in PowerApps. Can I run a query that I pass a ContextVariable to? Or do I have a DataSource that gets all tasks then somehow filter then based on the ContextVariable? 

 

Thanks in advance. 

Categories:
  • SinanE Profile Picture
    174 on at

    Hey James, have you considered creating App From Data using your sql connection? Sounds like the app you would like to generate is very similar to that.

     

    Click New, in start with your data, click the right arrow, and you will see SQL connection in the list. Proceed by choosing a table and click "Connect". You can then modify this auto-generated app.

     

     

    Check out this tutorial - it uses excel but the idea is the same:

     

    https://powerapps.microsoft.com/en-us/tutorials/get-started-create-from-data/

     

     

  • JamesM Profile Picture
    273 on at

    Hi SinanE, 

     

    I had a read of that tutorial but it didn't quite click with me (probably my failing). 

     

    Maybe if I explain what I'm trying to achieve it might make more sense. So on screen 1 I have a list of tasks. I have a navigate function to take me to screen 2 which (should have) the specific information about that task. Screen 2 is shown below: 

     

    2017-03-02 14_01_58-PowerApps.jpg

     

    I get the title for the screen by passing the ContextVariable through. I've done your suggestion of adding a Display "Form" to the screen connected to my data source of all tasks, and I've made the fields visible on the screen, but I'm still not quite clear on how to ensure the description, members etc are only related to the specific task I'm interested in 🙂 

  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @JamesM,

     

    In addition to the DataSource property, you would need to set the Item property of the Display form with the Gallery.selected:

    Item = Gallery.Selected

    in order to display the selected value.

    This way would make the record displays under your Screen2.

    16.PNG

    For more details, please check:

    Edit form and Display form controls in PowerApps

    If you have any further questions, please post back.

    Regards

  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @JamesM,

     

    Do you need any further help on this issue?

    Regards

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard