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

Count a Variable up

Hello,

 

I have the variable UpdateContext({_varseatstaken:0}) and a SharePoint lists with 6 columns which can be true/false. 

 

Now everytime a colum is true it should count +1 and if it´s false it should reset to 0 again for that colum. 

 

If(seat1=true,_varseatstaken+1);If(seat2=true,_varseatstaken+1);If(seat3=true,_varseatstaken+1);If(seat4=true,_varseatstaken+1);If(seat5=true,_varseatstaken+1);If(seat6=true,_varseatstaken+1);Patch('3floor_1',Gallery4.Selected,{taken_x0020_places:_varseatstaken})

I´ve tried a lot and didn´t got any solution. I also tried to do it without a Variable just with the column but didn´t get any results.

 

Would be happy if someone can help me.

 

Best Regards

14 REPLIES 14
BitLord69
Level 10

Re: Count a Variable up

You must use UpdateContext to change the value of the variable, so it will become like this:

 

If(seat1,UpdateContext({_varseatstaken:_varseatstaken+1})); etc...

Good luck!

Belasor
Level: Powered On

Re: Count a Variable up

First of all thank you for your help.

 

I have one question left.

I want to Patch the field in SharePoint with this function

Patch('3floor_1',Gallery4.Selected,{taken_x0020_places:_varseatstaken})

So normally it should work isn´t it?

 

However thank you.

BitLord69
Level 10

Re: Count a Variable up

To me it looks like it should work. Only one way to know for sure - try it out 🙂

Belasor
Level: Powered On

Re: Count a Variable up

Unfortunately it´s not working.

It´s not counting the variable correct.

 

;Refresh('some input')
;If(seat1=true,UpdateContext({_varseatstaken:_varseatstaken+1}));If(seat2=true,UpdateContext({_varseatstaken:_varseatstaken+1}));If(seat3=true,UpdateContext({_varseatstaken:_varseatstaken+1}));If(seat4=true,UpdateContext({_varseatstaken:_varseatstaken+1}));If(seat5=true,UpdateContext({_varseatstaken:_varseatstaken+1}));If(seat6=true,UpdateContext({_varseatstaken:_varseatstaken+1}))

;Patch('3floor_1',Gallery4.Selected,{taken_x0020_places:_varseatstaken})

 

It´s still not working. 

The problem this time is that if seat 1=true your getting 0 taken places and if seat1-seat4 are booked your getting 6 taken places it´s really strange.

davidstone
Level 8

Re: Count a Variable up

Belasor
Level: Powered On

Re: Count a Variable up

Is it possible, because I have a lot of SharePoint columns with yes/no

Highlighted
BitLord69
Level 10

Re: Count a Variable up

Put a label somewhere and let its Text-property be 

 

Text(_varseatstaken) 

 

What do you initiliaze the variable to, and when? Check to see when/how the variable changes value.

davidstone
Level 8

Re: Count a Variable up

You could do:-

 

CountIf(seat1) + CountIf(seat2) + ...etc.

 

Assuming you only have 6 columns - if you have many more, this wouldn't be the right way to go.

Belasor
Level: Powered On

Re: Count a Variable up

Thanks for your answer.

If I press a button it should set the value on true, which is working correctly because I can see in SharePoint the right values.

 

When seat1=true the value is 0

When seat2=true the value is 1

When seat3=true the value is 3

When seat4=true the value is 6

 

Could it be that we need something like Gallery.Selected stuff for the seats?

 

 

 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

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
Users online (4,272)