cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ramonjairo31
Helper II
Helper II

Start date and end date dynamic

Hello everyone, I need some help from you

I’m trying to take the overall start date, input that into the start date of the first line and then add the number of days to get the end date and then use this end date as the start date for the next line and so on, 

FB_IMG_1588816581383.jpg

 

Post data: I have the repeating table working fine so far what I need is update Start date and end date on the lines as described above. I need to have this done in PowerApps, This Picture is only to be illustrated by it 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Ramonjairo31 ,

Yes, since every record's start date and end date has relationship, so if you modify one record, you also need to modify other records.

For example:

if you make task1 to task3's original time, you need these formulas:

Patch(user_form1,LookUp(user_form1,task="task2"),
{'start date':LookUp(user_form1,task="task1",'start date'),//task1's start time
'end date':DateAdd(LookUp(user_form1,task="task1",'start date'),LookUp(user_form1,task="task2",days))  //task1's start time+days
});
Patch(user_form1,LookUp(user_form1,task="task1"),
{'start date':DateAdd(LookUp(user_form1,task="task3",'end date'),-LookUp(user_form1,task="task1",days)),//task3's end time+days
'end date':LookUp(user_form1,task="task3",'end date')});//task3's end time
Patch(user_form1,LookUp(user_form1,task="task3"),
{'start date':LookUp(user_form1,task="task2",'end date'),//task2's end time
'end date':LookUp(user_form1,task="task1",'start date'//task1's start time
}
)

//the order will become task2->task3->task1

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
eka24
Super User
Super User

Do you want to do this in Excel or Powerapps?

If in Powerapps, is it on a form

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

PowerApps 

eka24
Super User
Super User

Assuming you have only one line (One record ) and you want a second line or row:
Insert a TextBox1 and in the Default put:
LookUp(Table1,Decription=TextBox1.Text,EndDate) ...This will pull the old end date

 

If you have a TextBox2 which will record EndDate for next line/record put:

DateAdd(DateValue(TextInput5_3.Text),5)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Actually I need more than two lines, because this is repeating table, I have the repeating tablet working so far, 3A90FEBD-2074-4E56-9B25-2423C8A0EC61.jpeg

 

It's important you provide all information you have to enable people give the needed help when you ask the question.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Hi @Ramonjairo31 ,

Do you want to create a screen like the screenshoot that you provided?

Do you want the startdate will be the last enddate automatically, the end date will be the startdate+days?

If so, I've made a similar test for your reference:
1)my data source:

listname: user_form1

fieldname: start date(date type), end date(date type), days( number type), task(text type)

2)my app:
insert these controls: 2 textinputs, 2 datepickers, a submit button, a data table

set datepicker1's DefaultDate:

If(IsEmpty(user_form1),Today(),Last(user_form1).enddate)

set datepicker2's DefaultDate:

DateAdd(DatePicker1.SelectedDate,Value(TextInput2.Text))

set datepicker2's DisplayMode:

Disabled

set submit button's OnSelect:

Patch(user_form1,Defaults(user_form1),{task:TextInput1.Text,days:Value(TextInput2.Text),'start date':DatePicker1.SelectedDate,'end date':DatePicker2.SelectedDate});Reset(TextInput1);Reset(TextInput2)

set the datatable's Items:

user_form1

58.PNG

 

 

Then the screen will just like what you description.

Do not forget to replace the fieldnames, listnames,control names with yours.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the replied it,  this is working fine, however, there is a new request on this point which it's there is exist the possibility that task number 1 will be put down as task number 3 and now the amount of day is different so, need to recalculate all of this again

Hi @Ramonjairo31 ,

Yes, since every record's start date and end date has relationship, so if you modify one record, you also need to modify other records.

For example:

if you make task1 to task3's original time, you need these formulas:

Patch(user_form1,LookUp(user_form1,task="task2"),
{'start date':LookUp(user_form1,task="task1",'start date'),//task1's start time
'end date':DateAdd(LookUp(user_form1,task="task1",'start date'),LookUp(user_form1,task="task2",days))  //task1's start time+days
});
Patch(user_form1,LookUp(user_form1,task="task1"),
{'start date':DateAdd(LookUp(user_form1,task="task3",'end date'),-LookUp(user_form1,task="task1",days)),//task3's end time+days
'end date':LookUp(user_form1,task="task3",'end date')});//task3's end time
Patch(user_form1,LookUp(user_form1,task="task3"),
{'start date':LookUp(user_form1,task="task2",'end date'),//task2's end time
'end date':LookUp(user_form1,task="task1",'start date'//task1's start time
}
)

//the order will become task2->task3->task1

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,916)