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 / Canvas App Gallery - f...
Power Apps
Answered

Canvas App Gallery - filter items from one entity based on another

(0) ShareShare
ReportReport
Posted on by 5

Hi,

 

I'm trying to create a pool car booking app where by it forces people to share cars where available.

 

I have a form which asks for the users:

  • collection point
  • destination
  • collection time
  • return time

This then needs to display a gallery which contains a list of available cars (if there are any) which the user can then select.

 

My entities are:

Pool Car

Registration

Base Site

Available (yes/no)

 

Pool Car Bookings

Pool Car (related entity)

Start Date(date/time)

End Date (date/time)

destination(text)

 

I'm struggling to filter the gallery items based on the form.

 

In SQL I'd look to do something like this:

 

SELECT * FROM poolCars c WHERE NOT EXISTS( SELECT * FROM
	bookings b
	WHERE 
	(DATE_FORMAT(b.startDate, "%Y-%m-%d") = CURDATE() 
		AND b.passengers >= c.seats
	)
	AND b.poolCar_id = c.id
)

 

 

however I am unsure how to do this in PowerApps. Any ideas?

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,928 Most Valuable Professional on at

    Hi @CrystalShardz ,

    I will call the fields below

    • DestinationTxt
    • Pickup
    • Return

    For the moment, I will assume you are using (for the last two) the standard three element (Date, Hour, Minute) controls generated by PowerApps when adding a Date/Time card. I have not done any error control as all three items would need to be completed. You have mentioned some other parameters in your SQL, but I will deal with the three above to give you an idea of the syntax required for displaying all a list of cars that are going to a destination and leaving withing 30 minutes either side of the selected date/time and arriving within the same tolerance. I believe also you would need to query PoolCarBookings

    Filter(
     PoolCarBookings,
     Destination = DestinationTxt.Text 
     &&
     Abs(
     DateDiff(
     Pickup.SelectedDate + 
     Time(
     Value(Pickup.SelectedText.Value), 
     Value(Pickup.SelectedText.Value), 
     0
     ),
     StartDate,
     Minutes
     )< 30
     &&
     Abs(
     DateDiff(
     Return.SelectedDate + 
     Time(
     Value(Return.SelectedText.Value), 
     Value(Return.SelectedText.Value), 
     0
     ),
     EndDate,
     Minutes
     )< 30
    )

    Incidentally, if you use SharePoint as a backend, MS Access connects directly and all your SQL works perfectly - I use it extensively for generating Excel reports and also for dashboards.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • CrystalShardz Profile Picture
    5 on at

    Thanks for the code snippet 🙂 With your help i've managed to get what I was intending to work in my app.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard