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 / Set Collection Data if...
Power Apps
Answered

Set Collection Data if Datepicker is changed to sum all Items of every day (datepicker range)

(0) ShareShare
ReportReport
Posted on by 52

Hello,

 

i tried to implement this code to sum all items for each day in the range of the Datepicker. So each record in the collection should show the sum of all items seperated of one day. 

 

ClearCollect(WeekSummaryOrder);;

ForAll(
Sequence(DateDiff(DatePicker1_2.SelectedDate; DatePicker1_4.SelectedDate; TimeUnit.Days) + 1);
Collect(
WeekSummaryOrder;
{
Date: DateAdd(DatePicker1_2.SelectedDate; Value - 1; TimeUnit.Days);
MainDish1Count: CountRows(Filter(Gallery1_1.AllItems; MainDish = "Hauptgericht 1" && Date = DateAdd(DatePicker1_2.SelectedDate; Value - 1, TimeUnit.Days)));
MainDish2Count: CountRows(Filter(Gallery1_1.AllItems; MainDish = "Hauptgericht 2" && Date = DateAdd(DatePicker1_2.SelectedDate; Value - 1, TimeUnit.Days)));
MainDish3Count: CountRows(Filter(Gallery1_1.AllItems; MainDish = "Hauptgericht 3" && Date = DateAdd(DatePicker1_2.SelectedDate; Value - 1, TimeUnit.Days)));
}
)
);

 

Thanks in advance!

 

Categories:
I have the same question (0)
  • Verified answer
    BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at

    Hi @Bajda,

     

    Try including a reference to the current item in the ForAll loop (ThisRecord):

    ClearCollect(WeekSummaryOrder);;
    
    ForAll(
    	Sequence(DateDiff(DatePicker1_2.SelectedDate; DatePicker1_4.SelectedDate; TimeUnit.Days) + 1);
    	Collect(
    	WeekSummaryOrder;
    	{
    	Date: DateAdd(DatePicker1_2.SelectedDate; ThisRecord.Value - 1; TimeUnit.Days);
    	MainDish1Count: CountRows(Filter(Gallery1_1.AllItems; MainDish = "Hauptgericht 1" && Date = DateAdd(DatePicker1_2.SelectedDate; ThisRecord.Value - 1, TimeUnit.Days)));
    	MainDish2Count: CountRows(Filter(Gallery1_1.AllItems; MainDish = "Hauptgericht 2" && Date = DateAdd(DatePicker1_2.SelectedDate; ThisRecord.Value - 1, TimeUnit.Days)));
    	MainDish3Count: CountRows(Filter(Gallery1_1.AllItems; MainDish = "Hauptgericht 3" && Date = DateAdd(DatePicker1_2.SelectedDate; ThisRecord.Value - 1, TimeUnit.Days)));
    	}
    	)
    );

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard