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 / 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

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 May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard