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 / Remove record from col...
Power Apps
Unanswered

Remove record from collection that is populated using a calendar

(0) ShareShare
ReportReport
Posted on by 220

Hi, I have a calendar created:

TB05_0-1649688562309.png

The Onselect for the Continue button is:

Set(varBonusStartDate, DateValue(Text(_selectionStart, ShortDate)));
Set(varBonusEndDate, DateValue(Text(_selectionEnd, ShortDate)));
Collect(yourCollection,
ForAll(Sequence(DateDiff(varBonusStartDate, varBonusEndDate, Days)+1, 0),
{colDate: DateAdd(varBonusStartDate,Value, Days)}
)
);
Set(varBonusDateCount, CountRows(yourCollection));
UpdateContext({viewCalendar:false});

If I select Days 11 & 12, yourCollection will have those days added to the collection.  But, if I re-open the calendar and want to change the days selected to Days 10 & 11, in my collection I have 10, 11, 11, 12 days (4 days).  Instead of 10 and 11. How do I get 10 & 11 without clearing the collection all together?

TB05_1-1649688770282.png

TB05_2-1649688784574.png

I do have a button that will clear all:

UpdateContext({viewCalendar:false});
Clear(yourCollection);
Set(varBonusStartDate, Blank());
Set(varBonusEndDate, Blank());
Set(varBonusDateCount, Blank());

The code on the SELECT of the Day is:

If( Month(DateAdd(_firstDayInView,ThisItem.Value,Days))<>Month(_firstDayOfMonth),
0,

_selectedCount > 0
&& DateAdd(_firstDayInView,ThisItem.Value,Days) >= _selectionStart
&& DateAdd(_firstDayInView,ThisItem.Value,Days) <= _selectionEnd,
UpdateContext({_selectedCount: 0}),

_selectedCount = 1,
UpdateContext({_selectionStart: Min(_selectionStart, DateAdd(_firstDayInView,ThisItem.Value,Days)),
_selectionEnd: Max(_selectionStart, DateAdd(_firstDayInView,ThisItem.Value,Days)),
_selectedCount: 2}),

UpdateContext({_selectionStart: DateAdd(_firstDayInView,ThisItem.Value,Days),
_selectionEnd: DateAdd(_firstDayInView,ThisItem.Value,Days),
_selectedCount: 1}))

 

 

It seems to me that the issue is when I deselect the calendar day (no longer high-lighted) the _selectionStart and the _selectionEnd entry is still the last entry selected, they do not go back to blank.  Any thoughts on how to do that?  I guess it has to do with my count???  

Categories:
I have the same question (0)

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard