cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
pquateli
Frequent Visitor

Calculate the useful day in a gallery item when it is selected

Hello

 

I'm starting out on PowerApps and I'm having the following problem:

 

I have a gallery where I need to calculate the date for each item.

 

For the first item is easy, I just need to inform the date today, but for the other items, I need to calculate the date based on the date of the last selected item by adding the deadline of the current item.

 

For example, in the image below, the date displayed for the items #1 and #2 are correct. The dates of the items #3 and #4 must be blank and the date of the item #5 must be the date of the item #2 (last item selected) plus 10 days (the deadline is in the "Deadline column").

 

Additionally, if the calculated date is a Saturday or Sunday, the date of next Monday should be displayed.

 

Items in this gallery will always be sorted in ascending order by the "Seq." column.

 

Is it possible to do that?

 

Many thanks!

 

GalleryDates.PNG

2 REPLIES 2
Super User
Super User

Re: Calculate the useful day in a gallery item when it is selected

What you are looking for is DateAdd. Here's the details: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff For example: to add 10 days to the current date you would use: DateAdd( Today(), 10, Days) Note: Days is the default so technically you could just say DateAdd(Today(), 10) Dealing with the weekends is a little more complex. There are several posts which deal with this subject that I would suggest you review. The two primary posts (which are related) are: https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Auto-selecting-a-Date-that-doesn-t-... https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Date-Selection-No-Weekends-or-Holid...
pquateli
Frequent Visitor

Re: Calculate the useful day in a gallery item when it is selected

Hello LRVinC,
 
Thanks for your answer. I will read the posts you recommended about working with weekends and holidays.
 
I know DateAdd function but I what I realy need is to add the number of days to a date that is in another gallery item.
 
Taking the image from the previous message as an example, my DateAdd to calculate the date in item # 5 should look like this:
 
DateAdd (Date_from_Item_#2 (because itens #3 and #4 are not selected); Deadline_from_Item_#5; Days).
 
I keep looking for a solution (if I was working in VBA I would know how to solve ...)
 
Tks!
 

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (9,449)