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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Variable is always bee...
Power Apps
Unanswered

Variable is always been evaluated to False, even the If statment return true

(0) ShareShare
ReportReport
Posted on by 1,811 Super User 2024 Season 1
I have this set variable inside power app onvisible property of a screen:-

 
 
Set(varCanSubmitNoOfAttach,
If(!varNewProcess,true,
If(IsGIZDataCardValue.Value,
If("Up to EUR 1,000.00 " in cbProcuremenOptions.Selected.Value, true,
If("From EUR 1,000.00 to EUR 200,000.00" in cbProcuremenOptions.Selected.Value &&
(CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems) >= 3),true,
If("Over EUR 200,000.00" in cbProcuremenOptions.Selected.Value &&
(CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems) >= 1) , true
,
false
))),

If("between $3,000 to $24,999" in cbProcuremenOptions.Selected.Value && (CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems) >= 1), true,
If("between $25,000 to $100,000" in cbProcuremenOptions.Selected.Value && (CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems) >= 2), true,
If("above $100,001" in cbProcuremenOptions.Selected.Value && (CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems) >= 3), true
,
false
)))


)));
 



currently I changed the "cbProcuremenOptions.Selected.Value" to "Contract price between $25,000 to $100,000" and the CountRows(attachmentprocurement.Attachments) = 2 where i attached 2 attachments and the varNewProcess = true and IsGIZCardValue = false.. so i thought the varCanSubmitNoOfAttach will be true, but its value is false.. any advice?
Categories:
I have the same question (0)
  • timl Profile Picture
    36,415 Super User 2025 Season 2 on at
    Hi johnjohnPter 
     
    I would double check the values in your combo box control vs the values that you specify in your If statement. 
     
    In your description, you say that you selected "Contract price between $25,000 to $100,000", whereas the condition if your If statement specifies  "between $25,000 to $100,000" (eg, it's missing the "Contract price" prefix). This would be one reason why you don't see the expected result.
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at
    To make it easier to debug (I cannot see your data or desired logic), You only need to set out the combination of the various conditions that could possibly be true. This code returns either true or false
    With(
       {
          _Rows:CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems),
          _Options: cbProcuremenOptions.Selected.Value
       },
       Set(
          varCanSubmitNoOfAttach,
          !varNewProcess ||
          (
             IsGIZDataCardValue.Value && 
             (
                _Options = "Up to EUR 1,000.00" || 
                (_Options = "From EUR 1,000.00 to EUR 200,000.00" && _Rows >= 3) ||
                (_Options = "Over EUR 200,000.00" && _Rows >= 1) ||
                (_Options = "between $3,000 to $24,999" && _Rows >= 1) ||
                (_Options = "between $25,000 to $100,000" && _Rows >= 2) ||
                (_Options = "above $100,001" in _Options && _Rows >= 3)
             )
          )
       )
    )
     
    Please click 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 giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    I am not using "=", i am using "in" operator, and "between $25,000 to $100,000" is actually in "Contract price between $25,000 to $100,000"
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    I tried this formula based on yours, but still the variable will always be false:-
     
     
    With(
       {
          _Rows:CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems),
          _Options: cbProcuremenOptions.Selected.Value
       },
       Set(
          varCanSubmitNoOfAttach,
          !varNewProcess ||
          (
             IsGIZDataCardValue.Value &&
             (
                "Up to EUR 1,000.00" in _Options ||
                ("From EUR 1,000.00 to EUR 200,000.00" in _Options && _Rows >= 3) ||
                ("Over EUR 200,000.00" in _Options && _Rows >= 1)
                
             )
          )
          ||
          (
             !IsGIZDataCardValue.Value &&
             (
               
                ("between $3,000 to $24,999" in _Options && _Rows >= 1) ||
                ("between $25,000 to $100,000" in _Options && _Rows >= 2) ||
                ("above $100,001" in _Options && _Rows >= 3)
             )
          )
       )
    )
     
    is it because i am setting the variable inside the screen onvisible, and then i am attaching files? i do not thin so, as the variable should update its value based on the changes we make..
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at
    Just to confirm, that your requirement is that the following should return as true
    • "cbProcuremenOptions.Selected.Value" contains "between $25,000 to $100,000" AND
    • CountRows(attachmentprocurement.Attachments) = 2
    That certainly is one of the conditions, however additionally you also need the Variable varNewProcess and the control IsGIZDataCardValue to both be false - is this the case ? 
    Put this on a Label when you are selecting the value and see if it returns true.
    "between $25,000 to $100,000" in cbProcuremenOptions.Selected.Value
     
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    yes this label
    "between $25,000 to $100,000" in cbProcuremenOptions.Selected.Value 
    will show True, but the variable will be Blank()..
    i am not sure what is going on?
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at
    OK - try these on two Labels
    IsGIZDataCardValue.Value
    varNewProcess


  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
     
    Here is my test :-

    1) I set the IsGIZContract checkbox to true
    2) I attached 3 attachments
    3) I select "From EUR 1,00.00 to EUR 200,000.00"
     
    where all the 3 parameters return true, but the varCanSubmitNoOfAttach return false
     
     
     
     
     
     
    here is the variable value:-
     
     
     
    So not sure what is going on?
     
    Thanks
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at
    OK - some old-fashioned debugging required - there are three elements that are required to be true here to return a true result - I have highlighted them in blue
    With(
       {
          _Rows: CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems),
          _Options: cbProcuremenOptions.Selected.Value
       },
       Set(
          varCanSubmitNoOfAttach,
          !varNewProcess ||
          (
             IsGIZDataCardValue.Value &&
             (
                "Up to EUR 1,000.00" in _Options ||
                ("From EUR 1,000.00 to EUR 200,000.00" in _Options && _Rows >= 3) ||
                ("Over EUR 200,000.00" in _Options && _Rows >= 1)
             )
          ) ||
          (
             !IsGIZDataCardValue.Value &&
             (
               
                ("between $3,000 to $24,999" in _Options && _Rows >= 1) ||
                ("between $25,000 to $100,000" in _Options && _Rows >= 2) ||
                ("above $100,001" in _Options && _Rows >= 3)
             )
          )
       )
    )
    
     so there are three things you can put on Labels when you select the required items
    1.  CountRows(attachmentprocurement.Attachments) + CountRows(galAttachments_1.AllItems needs to be 3 or greater
    2. IsGIZDataCardValue.Value needs to be true
    3. "From EUR 1,000.00 to EUR 200,000.00" in cbProcuremenOptions.Selected.Value needs to be true
    Is all of the the case ?
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
    Thanks a lot for your help,
    Yes exactly, your code is valid, the statments in blue are true.. so why the final var will be false?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard