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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / problem with GroupBy a...
Power Apps
Unanswered

problem with GroupBy and filter

(0) ShareShare
ReportReport
Posted on by 9

I have a problem with a groupby-filter combination in a timekeeping app.

 

I have a screen where the user can select a period, a hidden control contains the username. A gallery shows the hours per day for the user in the selected period, using a GroupBy and Filter. Working fine. 

 

In the screen's OnVisible I use essentially the same code to show last week's hours so the gallery is filled when the user opens the screen (so the only difference is the code for the time period). However, in this case it refuses to filter on the username, and shows the hours per day for all users.

I tried a filter on the main table in advance, but even then,  the RegelsPerDag collection shows all users. 

 

My code:

 

UpdateContext({
DatumVanVullen:DateAdd(Today(), -1 * (Weekday(Today(), Monday) - 1)-7, Days),
DatumTotVullen:DateAdd(Today(), -Weekday(Today(), Monday), Days)});

 

ClearCollect( RegelsPerDag, GroupBy( Filter(tblTijdschrijfregel, MedewerkerAccessID= MijnMedewerkerAccessID, Datum >= DatumVanVullen, Datum < DatumTotVullen), "Datum", "Regels" ) );
ClearCollect( SomUrenPerDag, AddColumns( RegelsPerDag, "Uren", Sum(Regels, TijdsduurGewogenIntern ) ) );
ClearCollect( UrenPerDag, DropColumns(SomUrenPerDag, "Regels"));

 

Any idea what may be causing this weird behaviour in the onVisible? I'm stumped, because the code works correctly when started from the controls on the screen.

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    MedewerkerAccessID= MijnMedewerkerAccessID

    I assume from the above that MijnMedewerkerAccessID is the variable and MedewerkerAccessID is the column in the datasource?

     

    If you are setting this MijnMedewerkerAccessID during the App OnStart, your OnStart may not have completed when the page became visible.

    The non-blocking OnStart setting for an App makes the OnVisible and OnStart run in parallel.

     

    Could you provide some more info around how that variable is generated?

  • ingridvg Profile Picture
    9 on at

    Yes, the variable is set in onStart. However, this screen is not the Startscreen, so it is not shown directly after startup; and the problem occurs even when the app has been on for a while (e.g. the user has entered some time-keeping records, and then has a look at their totals). Other screens use the same variable, and have no issues.

     

    I also tried pre-filtering the collection by adding a line of ClearCollect(RegelsPerMedewerker, Filter(etc)); on top and then using the GroupBy on the RegelsPerMedewerker. Looking at the collections from the designer, I could see RegelsPerMedewerker containing the expected records, and RegelsPerDag still having unfiltered records. 

     

    Right now, my temporary solution is hiding the gallery until a control is selected but I want to understand what is going wrong. 

  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Yes I unfortunately can't answer why this isn't working - this should work and I couldn't replicate the issue 😞

    If you have a workaround that's great, hopefully someone else will have an explanation to add here

  • ingridvg Profile Picture
    9 on at

     Thank you for trying :-).

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard