cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Belasor
Helper III
Helper III

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
Memorable Member
Memorable Member

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!

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.

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

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.

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

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.

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.

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,729)