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 / Combobox update a numb...
Power Apps
Answered

Combobox update a number variable depending on No selection

(1) ShareShare
ReportReport
Posted on by 96
Hi,
 
I recently had advice about updating a number variable as long as the combobox had a value of "Yes" or "No" (in other words not blank.
 
i settled on this code as a Named Formula 
 
varBinCalcCheck =
If(!IsBlank(cmbQuestionOne.Selected), 1, 0) +
If(!IsBlank(cmbQuestionTwo.Selected), 2, 0) +
If(!IsBlank(cmbQuestionThree.Selected), 4, 0) +
If(!IsBlank(cmbQuestionFour.Selected), 8, 0) +
If(!IsBlank(cmbQuestionFive.Selected), 16, 0) 
;
 
Which i then used in the On Change event using fx code to send a warning depending on the number value of: varBinCalcCheck.
 
I have tried to adapt the code by amending to check if the value of the Combobox = "No" but i am getting an error - saying about a Record and Test error.
 
The code i have tried is:
 
If(!IsBlank(cmbQuestionOne.Selected && cmbQuestionOne.Selected ="No"), 1, 0) +
 
so i would have had:
 
varBinCalcCheckNoSelected =
If(!IsBlank(cmbQuestionOne.Selected && cmbQuestionOne.Selected ="No"), 1, 0) +
If(!IsBlank(cmbQuestionTwo.Selected && cmbQuestionTwo.Selected ="No"), 2, 0) +
If(!IsBlank(cmbQuestionThree.Selected && cmbQuestionThree.Selected ="No"), 4, 0) +
If(!IsBlank(cmbQuestionFour.Selected && cmbQuestionFour.Selected ="No"), 8, 0) +
If(!IsBlank(cmbQuestionFive.Selected && cmbQuestionFive.Selected ="No" ), 16, 0) 
;
 
Thereby hoping to get a count of Comboboxes that + "No" (using Binary)
So if i had 
cmbQuestionOne = "No"
cmbQuestionTwo = ""
cmbQuestionThree = "No"
cmbQuestionFour = "Yes"
cmbQuestionFive = "No"
 
Then 
varBinCalcCheckNoSelected = 21
 
Please could someone suggest how to fix this code so it can equate if the combobox value ="No" NOT just "Non Blank"
 
varBinCalcCheckNoSelected =
If(!IsBlank(cmbQuestionOne.Selected), 1, 0) +
If(!IsBlank(cmbQuestionTwo.Selected), 2, 0) +
If(!IsBlank(cmbQuestionThree.Selected), 4, 0) +
If(!IsBlank(cmbQuestionFour.Selected), 8, 0) +
If(!IsBlank(cmbQuestionFive.Selected), 16, 0) 
;
 
Thanks 
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    The fundamental issue is to refer to a String value, you need the output field, not the Table/Record from the Combo Box - assuming the DisplayFields  is Value, then you can do this
    varBinCalcCheckNoSelected =
    If(cmbQuestionOne.Selected.Value = "No", 1, 0) +
    If(cmbQuestionTwo.Selected.Value = "No", 2, 0) +
    If(cmbQuestionThree.Selected.Value = "No", 4, 0) +
    If(cmbQuestionFour.Selected.Value = "No", 8, 0) +
    If(cmbQuestionFive.Selected.Value = "No", 16, 0)
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
     
  • Suggested answer
    Haque Profile Picture
    3,653 on at
     
    Yes I can remember your previous post/thread where I suggested a complete end to end user defined function sample. However, the below code should work that I tested also.
     
     
            Set( varBinCalcCheck,
            If(cmbQuestionOne.Selected.Value in ["Yes", "No"], 1, 0) +
            If(cmbQuestionTwo.Selected.Value in ["Yes", "No"], 2, 0) +
            If(cmbQuestionThree.Selected.Value in ["Yes", "No"], 4, 0) +
            If(cmbQuestionFour.Selected.Value in ["Yes", "No"], 8, 0) +
            If(cmbQuestionFive.Selected.Value in ["Yes", "No"], 16, 0)
            );
            
            lblResult.Text = Text(varBinCalcCheck)
     
     
    One user result is given below:
     
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard