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 / Filtering a gallery co...
Power Apps
Unanswered

Filtering a gallery control

(0) ShareShare
ReportReport
Posted on by 18

Hi Guys,

 

I'm hoping someone can help me because i'm stuck on this issue and chat gpt has not been too helpful so I need some real help 😉

 

I have two tables, Maintenances which lists all maintenance checks for a car. The second table is MaintenanceChecks which contains all checks performed by staff.

 

I have a gallery control on our mobile app and I want it to only show maintenances entries where there is no maintenance check performed within a specified timeframe.

 

I have this in the items function box: 

 

Filter(Maintenances, ID in Filter(MaintenanceChecks, CheckDate <= DateAdd(Now(),FrequencyInDays-(FrequencyInDays*2),TimeUnit.Days)).MaintenanceID)

 

I need to modify the inner filter to only return the latest entries because it evaluates older checks when I only want the latest check.

Filter(MaintenanceChecks, CheckDate <= DateAdd(Now(),FrequencyInDays-(FrequencyInDays*2),TimeUnit.Days)).MaintenanceID

 

The issue is that the 'check tyres' entry in maintenances shows in the gallery even if someone checked the tyres today because its evaluating dates on older entries too. 


If you understand this and can help please do!

 

Thanks.

 

 

 

 

 

 

Categories:
  • Ian-Waters Profile Picture
    18 on at

    Tables referenced for info..

     

    MaintenanceChecks.png

     

    Maintenances.png

     

  • Sickle-Cell Profile Picture
    600 Super User 2024 Season 1 on at

    Hi Ian,

    Is the CheckDate field referencing the date of the check, or the date it would next be checked?

    I'm also not sure if you're looking for the last check performed on a certain field, or just so it will stop looking for checks performed on the day. 


  • Ian-Waters Profile Picture
    18 on at

    Checkdate is the date the person performed the check so I only really want to evaluate the last entry for the check. I think it needs a group by 'MaintenanceID' then select the last entry then only evaluate on that.

     

    So the gallery control should only show the maintenances entries that havent had a check performed based on the frequencyInDays column.

    This is what the page looks like:
    checksdue.png

     

     

  • Ian-Waters Profile Picture
    18 on at

    So in this screenshot even if I perform a maintenance check of the 'Lights' the gallery control still shows the 'lights' maintenance because there are older checks where the checkdate is older than the frequencyindays.

     

    So I need to ignore older checks or group by MaintenanceID and grab the last entry for each then evaluate based on the results.

     

    Just FYI 'maintenancechecks' contains entries from 'maintenances' so there is a record at the point of the check. So if someone changes any entries the actual data at the point of the check is saved.

  • Sickle-Cell Profile Picture
    600 Super User 2024 Season 1 on at

    Hi Ian,

     

    I think there are two options for what you're looking for. You can either set up the app to remove earlier records when a new one is sumbitted or try the Distinct function, which removes duplicates. Something like this might work.


    Distinct(Filter(Maintenances, ID in Filter(MaintenanceChecks, CheckDate <= DateAdd(Now(),FrequencyInDays-(FrequencyInDays*2),TimeUnit.Days)).MaintenanceID),MaintenanceID)

  • Ian-Waters Profile Picture
    18 on at

    Thanks, I may use your first idea and have a third table of historical checks then when a check is added remove any older ones then add the entry to the historical checks table too.

     

    I can make that work but would be nice to solve it in one function.

     

  • Sickle-Cell Profile Picture
    600 Super User 2024 Season 1 on at

    Hi Ian,

     

    No problem. Depending on how many records you have, the first option may be tidier as it'll avoid any potential delegation issues in future. 

    Another thought I've just had if you're just looking for the most recent check, you could use the First or Last function to only return the one you're looking at. Not sure what the exact syntax would be in your use case. 

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 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard