web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using a variable withi...
Power Apps
Answered

Using a variable within a form based on conditions

(0) ShareShare
ReportReport
Posted on by 580

Hi All, 

 

I'm trying to get my head around a problem. I have a form that uses a variable to count checkbox's 'ticked' which then assigns a value and adds the values up at the bottom of the form to give a total. On submission of a new form, the total output of the variable value is saved back to a SP list - As described in this post by @Drrickryp : https://powerusers.microsoft.com/t5/Building-Power-Apps/Set-a-numerical-value-to-a-checkbox-amp-total-amount-of-checked/m-p/1566207#M402739

 

The problem I have is, I need to edit these forms, but when you edit the form, the totals at the bottom are still set to use a variable rather than the Parent.Default data from the SP List and they show up blank, ideally this needs to display the Parent.Default. Which leads me to my next problem, If I need to edit any of the checkbox's on the form, I need the form to adjust the totals at the bottom to then be saved back to the SP list on submission. 

 

Any advice?

 

 

Categories:
I have the same question (0)
  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @AdamH 

    You can use Coalesce() to find the first nonzero element,  IE. Coalesce(var, Parent.Default) with result in Parent.Default if var is blank.  If both are blank, the result will be blank. 

  • AdamH Profile Picture
    580 on at

    @Drrickryp 

    I tried your idea and have a few questions because I have never used Coalesce before.

    Default - Coalesce(var300, Parent.Default) gave a value of "55" which was the Parent.Default SP saved value. 

     

    But when I removed a check from a box, the value dropped to "-5" not "50" and then when I replaced the check, the value set to "0". "5" points being the value given to var300 - UpdateContext({var300:var300+5})

     

    When I checked a box that had not been checked before, the value went to "5". So does Coalesce compare the value in the SP list to what's happening in the app and then adjusts the SP List + or - ?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @AdamH

    Coalesce evaluates the contained elements from left to right until a non blank element is found. 

  • AdamH Profile Picture
    580 on at

    @Drrickryp 

     

    I changed it a little and this seems to work for me. 

     

    Coalesce(Sum(var300, Parent.Default)) - That is probably what you meant in the first place, but I removed the Sum( and it went wrong. 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    tenor (1).gif

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 400 Most Valuable Professional

#2
11manish Profile Picture

11manish 141 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard