cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous_Hippo
Super User
Super User

Set the Last value of a date picker to another date picker when its value changes

Hi all,

 

I'm trying to set a last value of a date picker to another date picker when its value changes. For example 

 

Anonymous_Hippo_1-1629763572227.png

Whenever the value of A changes I update the last saved value to "Previous value of A"  .

 

I know that i can easily do this using a variable but since there is already a value in "Previous value of A" field things become confusing to me. This seems so easy but my brain isn't working

 

Thanks for your help

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous_Hippo
Super User
Super User

Hello @v-bofeng-msft ,

 

Thank you for sharing such a great idea !  I wanted to point out that in your method it worked only after the 2nd change because the first time i change the value it saves the new value and not the old one. To fix this issue while doing a clear collect i saved the current value of A.

ClearCollect(
    Selectlog,
    {Value: Avalue}
);

In this way we were always comparing the right value.

 

Thanks ! a great learning point 🙂 have a nice day

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @Anonymous_Hippo :

Do you want to get something like this:

1.gif

I've made a test for your reference——

I assume 'Previous value of A''s Default value is 

Today()

'A'

OnChange

Set(
    IfChange,
    true
);
Reset('Previous value of A');
Collect(
    Selectlog,
    Self.SelectedDate
)

'Previous value of A'

DefaultDate

If(
    IfChange,
    First(
        LastN(
            Selectlog,
            2
        )
    ).Value,
    Today()
)

 Best Regards,

Bof

Anonymous_Hippo
Super User
Super User

Hello @v-bofeng-msft ,

 

Thank you for sharing such a great idea !  I wanted to point out that in your method it worked only after the 2nd change because the first time i change the value it saves the new value and not the old one. To fix this issue while doing a clear collect i saved the current value of A.

ClearCollect(
    Selectlog,
    {Value: Avalue}
);

In this way we were always comparing the right value.

 

Thanks ! a great learning point 🙂 have a nice day

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,404)