Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • ingridvg Profile Picture
    9 on at
    Re: problem with GroupBy and filter

     Thank you for trying :-).

  • iAm_ManCat Profile Picture
    18,201 Most Valuable Professional on at
    Re: problem with GroupBy and filter

    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
    Re: problem with GroupBy and filter

    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,201 Most Valuable Professional on at
    Re: problem with GroupBy and filter

    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?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard