cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Corissandageri
Post Patron
Post Patron

GroupBy Gallery showing wrong numbers until data refreshed

Hi all

In the home stretch of finishing my current app, but what I am finding is my Gallery is showing the wrong totals until I hit refresh, I will be accumulating a lot of records and I was hoping not to be refreshing data too often. This is the Gallery that's showing the wrong totals.

AddColumns(
    SortByColumns(
        Filter(
            GroupBy(
                Sanford_Pallet_Serial_Number_Record,
                "DateOfProduction",
                "SNDumped",
                "SNGroup",
                "PalletNumber",
                "OPProductCode",
                "DataPool"
            ),
            DateOfProduction >= DatePicker01_1.SelectedDate && DateOfProduction <= DatePicker02_1.SelectedDate
        ),
        LabelSwitchCode.Text,
        Descending
    ),
    "ItemCount",
    CountRows(DataPool),
    "FSNumber",
    First(DataPool).SerialNP,
    "LSNumber",
    Last(DataPool).SerialNP

Which gets fed from this.

UpdateContext({loadSpinner:true}); ClearCollect(GeneratedSNumbers, GalleryNumsGen.AllItems);ForAll(GeneratedSNumbers,Patch(Sanford_Pallet_Serial_Number_Record,Defaults(Sanford_Pallet_Serial_Number_Record),{SerialNP:GalGSNumbers.Text,LotNumber:TILLotNumberFull.Text,DateOfProduction: Now(),OPProductCode:GalleryOpCode.Selected.Value,SFProductCode:LabelSFCode.Text,SNGroup:LabelSFGrade.Text}));UpdateContext({loadSpinner:false})

 Which gets it's sequence from here.

Sequence(Value(TIQtyGenerated.Text),Value(FSNumber.Text))

 Clear as custard I'm sure.

3 REPLIES 3
RandyHayes
Super User
Super User

@Corissandageri 

I cannot tell from your formulas, but what is Sanford_Pallet_Serial_Number_Record?  Is that your datasource or is it a collection or variable?

If you are working directly with the datasource in all places (filters, patches, etc) then your Gallery will refresh the groupby information automatically.  If you are working with collections or variables, they are only snapshots in time and will need to be updated.  This is not to say that you have to refresh the datasource (as PowerApps will already have the refreshed information when you patch), but you would have to refresh your collections or variables as they are static.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy

Sorry for the delayed reply, I have been trying to work it out myself. Sanford_Pallet_Serial_Number_Record is the datasource. It would seem the actual data is correct because I have a separate gallery showing the data. But it does not seem to count rows reliably.

AddColumns(
    SortByColumns(
        Filter(
            GroupBy(
                Sanford_Pallet_Serial_Number_Record,
                "DateOfProduction",
                "SNDumped",
                "SNGroup",
                "PalletNumber",
                "OPProductCode",
                "DataPool"
            ),
            DateOfProduction >= DatePicker01_1.SelectedDate && DateOfProduction <= DatePicker02_1.SelectedDate
        ),
        LabelSwitchCode.Text,
        Descending
    ),
    "ItemCount",
    CountRows(DataPool)
    
)

When I change what I filter by(LabelSwitchCode.Text), it corrects itself.

I have moved the filter, but that has not improved the countrows reliability

AddColumns(
    SortByColumns(
            GroupBy(
        Filter( Sanford_Pallet_Serial_Number_Record,           
DateOfProduction >= DatePicker01_1.SelectedDate && DateOfProduction <= DatePicker02_1.SelectedDate),
                "DateOfProduction",
                "SNDumped",
                "SNGroup",
                "PalletNumber",
                "OPProductCode",
                "DataPool"
            ),

        LabelSwitchCode.Text,
        Descending
    ),
    "ItemCount",
    CountRows(DataPool)
    
)

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,262)