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
Power Participant
Power Participant

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.

BitLord69
Power Participant
Power Participant

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

BitLord69
Power Participant
Power Participant

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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