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

Toggle changing value in Excel table

I have a toggle control whose default value is set to If(ThisItem.IsVolunteer= "True", true, false) which when shown, sets it to on or off based on the True or False value in that cell of an Excel sheet and hence the table.  I've set the toggle's OnCheck property to ThisItem.IsVolunteer = "true" and OnUncheck value to ThisItem.IsVolunteer = "false" but turning the toggle on or off doesn't update the Excel table.

 

I'm pretty sure that's because the value is a comparison and not an action to change the value, but what should the OnCheck and OnUncheck values be? 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Toggle changing value in Excel table

Hi @Geordie,

 

Could you please share a bit more about your Excel table?

Is there a column called ID within your Excel table?

Further, could you please share a screenshot about your app's configuration?

 

I think there is something wrong with the formula that you provided. The Update function is used to update the replace an entire record in a data source, if you don't provide values for corresponding columns, the corresponding columns would be blank.

 

More details about the Update function in PowerApps, please check the following article:

Update function

 

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

 

Within the Gallery control, add a Toggle control within the Gallery control:

 

Set the Default property of the Toggle control to following formula:

If(ThisItem.IsVolunteer="true",true,false)

Set the OnCheck property of the Toggle control to following formula:

UpdateIf(Table1,ID=ThisItem.ID,{IsVolunteer:"true"});Refresh(Table1)

Set the OnUncheck property of the Toggle control to following formula:

UpdateIf(Table1,ID=ThisItem.ID,{IsVolunteer:"false"});Refresh(Table1)

Note: I assume that there is a column called ID within your Excel table. The Table1 represents the Excel table data source within your app.

 

In addition, you could also use the following workaround:

 

Set the OnCheck property of the Toggle control to following formula:

Patch(Table1,ThisItem,{IsVolunteer:"true"});Refresh(Table1)

Set the OnUncheck property of the Toggle property to following fomrula:

Patch(Table1,ThisItem,{IsVolunteer:"false"});Refresh(Table1)

 

Best regards,

Kris

 

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.
3 REPLIES 3
Geordie
Level: Powered On

Re: Toggle changing value in Excel table

If it helps, I'm sort of half way there.  

The OnUncheck value is now Update(Table1, First(Filter(Table1, ID=BrowseGallery1.Selected.ID)), {IsWelcomer:"False"} )

(this is the actual values, the original question generalised fields a little) This is meant to find the record in the sheet that has the value in the column called ID, that is the same as the main screen user's ID, and change the value in that row's IsWelcomer column to False. The app is throwing the error "_PowerAppsId_ required"

 

Does this mean that my filter *must* search for a record by the _PowerAppsId_ column that PowerApps inserts? If not, what does it mean? The way my data is structured is the ID column is the primary key...

Community Support Team
Community Support Team

Re: Toggle changing value in Excel table

Hi @Geordie,

 

Could you please share a bit more about your Excel table?

Is there a column called ID within your Excel table?

Further, could you please share a screenshot about your app's configuration?

 

I think there is something wrong with the formula that you provided. The Update function is used to update the replace an entire record in a data source, if you don't provide values for corresponding columns, the corresponding columns would be blank.

 

More details about the Update function in PowerApps, please check the following article:

Update function

 

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

 

Within the Gallery control, add a Toggle control within the Gallery control:

 

Set the Default property of the Toggle control to following formula:

If(ThisItem.IsVolunteer="true",true,false)

Set the OnCheck property of the Toggle control to following formula:

UpdateIf(Table1,ID=ThisItem.ID,{IsVolunteer:"true"});Refresh(Table1)

Set the OnUncheck property of the Toggle control to following formula:

UpdateIf(Table1,ID=ThisItem.ID,{IsVolunteer:"false"});Refresh(Table1)

Note: I assume that there is a column called ID within your Excel table. The Table1 represents the Excel table data source within your app.

 

In addition, you could also use the following workaround:

 

Set the OnCheck property of the Toggle control to following formula:

Patch(Table1,ThisItem,{IsVolunteer:"true"});Refresh(Table1)

Set the OnUncheck property of the Toggle property to following fomrula:

Patch(Table1,ThisItem,{IsVolunteer:"false"});Refresh(Table1)

 

Best regards,

Kris

 

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.
Geordie
Level: Powered On

Re: Toggle changing value in Excel table

Thanks heaps Kris, Patch was what I was after and that syntax - once modified to meet my actual app - works fine. Sorry that the question was a bit vague, but this app has live user data in it including names, cell numbers and email addresses which makes it really hard to show screenshots etc. Smiley Happy  Thanks for the correct answer and helping me!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 40 members 4,197 guests
Recent signins:
Please welcome our newest community members: