cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DonBo
Level: Powered On

how to set variable for last value

I need to save a last value of a dropdown control and maintain the previous value as the dropdown control update to a new value.

 

Here is my meager attempt.  But this doesn't work.

 

If(Not(varTargetLang = varLastTargetLang), Set(varLastTargetLang, varTargetLang))

 

The last value needs to be stored even when the app is closed and reopened.  Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: how to set variable for last value

Hi @DonBo ,

Could you please share a bit more about your scenario?

Do you want to store the last selected value within the Dropdown box?

 

Based on the needs that you mentioned, I think the OnSelect property of the Dropdown box and a Collection could achieve your needs.

I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the Dropdown box to following:

ClearCollect(LastSelectedValue, Dropdown1.Selected.Value)

the last selected value would be stored within the LastSelectedValue collection.

 

If you want to save your Last selected from the Dropdown box even when close or re-open your app, I think the SaveData function and LoadData function could achieve your needs.

Please set the OnSelect property of the Dropdown box to following:

ClearCollect(LastSelectedValue, Dropdown1.Selected.Value);
SaveData(LastSelectedValue,"LocalData")

Set the OnStart property of the App control to following:

LoadData(LastSelectedValue, "LocalData", true)

Note: You can't use SaveData and LoadData function inside a browser, either when authoring the app in PowerApps Studio or when running the app in the web player. To test your app, run it in PowerApps Mobile on an iPhone or Android device.

 

More details about SaveData function, and LoadData function, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-savedata-loaddata

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
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

2 REPLIES 2
dyee4614
Level: Powered On

Re: how to set variable for last value

I don't know if this is the best way to do this but here is what I did when I had a similar problem.  I created a collection and left the answer blank.  Whenever there was a selection made, I patched the value into my collection.  On my next page or submit or whatever, I set it to reset the value of that collection so it always returns to the default when you leave.  

 

The only way around the close/reopen issue I can think of is SaveData and LoadData.  You can use SaveData to save a copy of the data on your device locally and use LoadData to pull the last entry.  

 

Note: The first time someone uses the app, there will be nothing to load so you will get an error message.  This will go away after you save data for the first time. 

Community Support Team
Community Support Team

Re: how to set variable for last value

Hi @DonBo ,

Could you please share a bit more about your scenario?

Do you want to store the last selected value within the Dropdown box?

 

Based on the needs that you mentioned, I think the OnSelect property of the Dropdown box and a Collection could achieve your needs.

I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the Dropdown box to following:

ClearCollect(LastSelectedValue, Dropdown1.Selected.Value)

the last selected value would be stored within the LastSelectedValue collection.

 

If you want to save your Last selected from the Dropdown box even when close or re-open your app, I think the SaveData function and LoadData function could achieve your needs.

Please set the OnSelect property of the Dropdown box to following:

ClearCollect(LastSelectedValue, Dropdown1.Selected.Value);
SaveData(LastSelectedValue,"LocalData")

Set the OnStart property of the App control to following:

LoadData(LastSelectedValue, "LocalData", true)

Note: You can't use SaveData and LoadData function inside a browser, either when authoring the app in PowerApps Studio or when running the app in the web player. To test your app, run it in PowerApps Mobile on an iPhone or Android device.

 

More details about SaveData function, and LoadData function, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-savedata-loaddata

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
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
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,008)