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 / Sum of result of a fil...
Power Apps
Unanswered

Sum of result of a filter on a collection

(0) ShareShare
ReportReport
Posted on by 302

Hey there,

I have an app where I need to have a gallery with the following;

It need to count the rows based on a dropdown with the order number, the company name and between 2 selected dates. I almost got it working like it should, but it is somehow counting wrong. Hopefully someone here can spot the mistake. 

This is how it looks (aantal = count): 

efeewfew_0-1657780403695.png

But when I select only the 21-06-2022 one, I get the following result (12), as also shown in the picture above:

efeewfew_1-1657780553015.png

But when I use countrows function on the collection with the same filter, I get 13 (the answer is actually 13, so the 12 is wrong)
Code for the result of 13;

 

CountRows(
 Filter(colCombined; 
 Order0 = Dropdown_Order_1.Selected.Result && 
 Geopperd = "TRUE" && 
 // Geopperddatum is the date in the collection
 (DateValue(Geopperddatum)>=StartDatumPicker.SelectedDate && DateValue(Geopperddatum)<=EindDatumPicker.SelectedDate)
 )
)

 


Code of the gallery which is a bit more complex, but uses the exact same filters. There is a dropdown to change between: "Geopperd, Gemonteerd and Opgeleverd", but for now we can focus on just "Geopperd", as I used that for the example

 

SortByColumns(
 AddColumns(
 GroupBy( 
 AddColumns(
 Filter(
 Sort(colCombined; ID; Descending);
 If(
 Dropdown_MontageOptie.Selected.Value = "Geopperd"; 
 Geopperd = "TRUE" && (DateValue(Geopperddatum)>=StartDatumPicker.SelectedDate && DateValue(Geopperddatum)<=EindDatumPicker.SelectedDate);


 Dropdown_MontageOptie.Selected.Value = "Gemonteerd"; 
 Gemonteerd = "TRUE" && (DateValue(Gemonteerddatum)>=StartDatumPicker.SelectedDate && DateValue(Gemonteerddatum)<=EindDatumPicker.SelectedDate);


 Dropdown_MontageOptie.Selected.Value = "Opgeleverd"; 
 Opgeleverd = "TRUE" && (DateValue(Opgeleverddatum)>=StartDatumPicker.SelectedDate && DateValue(Opgeleverddatum)<=EindDatumPicker.SelectedDate) 
 ) &&
 Order0 = Dropdown_Order_1.SelectedText.Result &&
 (bedrijfNaam = MontageFirma || bedrijfNaam = MontageFirma2)

 );
 "opgeleverdDatumSamengesteld";
 Opgeleverddatum;
 "opgeleverdSamengesteld";
 Opgeleverd;
 "montageFirma";
 MontageFirma;
 "montageFirma2";
 MontageFirma2;
 "orderNummer";
 Order0
 ); 
 // Group by gedeelte
 "opgeleverdDatumSamengesteld";
 "montageFirma";
 "montageFirma2";
 "orderNummer";
 "sumOpgeleverd"
 );

 // 2e Add columns formule
 "sumOpgeleverdCount";
 Sum(
 sumOpgeleverd;
 If(
 Dropdown_MontageOptie.Selected.Value = "Geopperd"; 
 Geopperd = "TRUE" && (DateValue(Geopperddatum)>=StartDatumPicker.SelectedDate && DateValue(Geopperddatum)<=EindDatumPicker.SelectedDate);


 Dropdown_MontageOptie.Selected.Value = "Gemonteerd"; 
 Gemonteerd = "TRUE" && (DateValue(Gemonteerddatum)>=StartDatumPicker.SelectedDate && DateValue(Gemonteerddatum)<=EindDatumPicker.SelectedDate);


 Dropdown_MontageOptie.Selected.Value = "Opgeleverd"; 
 Opgeleverd = "TRUE" && (DateValue(Opgeleverddatum)>=StartDatumPicker.SelectedDate && DateValue(Opgeleverddatum)<=EindDatumPicker.SelectedDate) 
 ) &&
 Order0 = Dropdown_Order_1.SelectedText.Result &&
 (bedrijfNaam = MontageFirma || bedrijfNaam = MontageFirma2)
 )
 );

 // SortBy
 "opgeleverdDatumSamengesteld";
 Descending
)

 

 

I've been stuck on this for a while, so any help is much appreciated! If there is an easier way to do this with less code, also let me know 🙂   (This also takes quite some time to calculate)

Categories:
I have the same question (0)
  • BCLS776 Profile Picture
    8,994 Moderator on at

    To get a count of rows that matches what is shown in the gallery, do your CountRows() on the gallery itself:

     

    CountRows(myGalleryName.AllItems)

     

    Hope that helps,

    Bryan

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 414

#2
Valantis Profile Picture

Valantis 408

#3
timl Profile Picture

timl 339 Super User 2026 Season 1

Last 30 days Overall leaderboard