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 / Number Value Comparison
Power Apps
Answered

Number Value Comparison

(0) ShareShare
ReportReport
Posted on by 129

Hello Guys/@yashag2255,

 

I have an issue with data comparison

 

Visibility property for (errormessage)

If(Value(DataCardValue9.Text) > Value(compassionateleavebalance.Text),true, false )

 

in app testing it works well, but when published it does not work well, the error message displays when any digit is typed into the (DatacardValue9.Text) field even if it is actually less than the DataCardValue9.

Please help  guys


 

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @abieba 

    Can you try this and post a screen shot of the result?  Please make 2 new labels and input the following in the Text property of the labels:

     

    • DataCardValue9.Text
    • compassionateleavebalance.Text

     

    Are they the values you expected?  Send us a screen shot showing the labels and the error message.

     

    ---
    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

     

  • abieba Profile Picture
    129 on at

    Yes they are values expected, 
    the app works well as expected when running a test while in power apps
    but after publishing the application, while trying to run it as an ordinary user the comparison does not work well then.

     

     

    That error message should only show up if the value inputed is greater than the annual leave balance which is 15 in this case 
    i typed in    '1' in the field and thats the outcome first is testing while designing second is testing after publishing to the intranet   (same account) 

    Testing the app while in powerapp designTesting the app while in powerapp designtesting the app running it as a separate apptesting the app running it as a separate app

  • abieba Profile Picture
    129 on at

    I think the problem is it takes a longtime for the value of Value(compassionateleavebalance.text) to be gotten, because after a while of waiting on the page, the app works in order.

    i called the Value(compassionateleavebalance.text) from a label (ThisItem.'compassionateleavebalance') in a gallery whose data source is 'Leave Balance List'   on another screen,
    how can i make the app load faster?

  • mdevaney Profile Picture
    29,991 Moderator on at

    @abieba 

    Using variables or collections to store data in memory is a common way to improve app performance rather that calling it from the datasource each time.

     

    From what I understand your app has 2 screens.  Screen1 has a gallery and the user selects an Item to Navigate to Screen2.  Add the following code to your gallery's OnSelect property

     

    Navigate(Screen2, None); 
    Set(CompassionateLeaveBalance, Value(ThisItem.'compassionateleavebalance'));

     

    Then on Screen2, change the Visible property of your error message to:

     

    If(Value(DataCardValue9.Text) > CompassionateLeaveBalance,true, false )

     

    If your theory about the app being slow to load is correct I think my approach will work.  Let me know.

     

    ---

    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

     

     

  • abieba Profile Picture
    129 on at

    @mdevaney 
    Is there i a away i can load it onstart of the application.

     

    There is a list called Leave Balance List with different users and their leave balance, here we have Annual Leave Balance, Sick LeaveBalance and Compassionate Leave Balance.

    There is another list where all leave applications are submitted (Leave Applications)

     

    Both lists have Staff Names. 
    How can i call the app to pick the all the values of Leave Balance (Annual, Sick, Compassionte) on start of the application for the current user logged on. this way it might just be faster.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @abieba 

    To pick the all the values of Leave Balance when the application loads put the following code into the OnStart property of your app

     

    Collect(LeaveBalances,First(Filter(your_leave_balance_list_name,UserName = User().FullName)));
    Set(AnnualLeaveBalance,LeaveBalances.your_annual_column_name);
    Set(CompassionateLeaveBalance,LeaveBalances.your_compasionate_column_name);
    Set(SickBalance,LeaveBalances.your_sick_column_name);

     

    You'll want to understand how the User() function works.  User().FullName returns the current user's full name in the format below.  You will have to have a matching column called UserName in the Leave Balance list.

     

    Andrew Bernard

     

    Alternatively, you could try User().Email instead.  This would ensure everyone has a unique ID (example: two people might have the same name Jim Smith).

     

    abernard@theoffice.com

     

    ---
    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

  • abieba Profile Picture
    129 on at

    Hi @mdevaney 

    i have this now

     

    Collect(LeaveBalances,First(Filter('Leave Balance List','Staff Name'.Email = CurrentUserEmail)));

    Set(AnnualLeaveBalance,LeaveBalances.'Annual Leave Balance');
    Set(AnnualLeaveBalance,LeaveBalances.'Sick Leave Balance');
    Set(AnnualLeaveBalance,LeaveBalances.'Compassionate Leave Balance');

     

    No errors now how do i do the comparison now in the visibilty property of my error message



    initially it was

    If(Value(DataCardValue14.Text) > Value(Label4.Text) ,true, false)  it was working but was delaying at startup 
    value in red hold the value of the annual leave balance of the logged on user



    Now how do i use the collected value 'AnnualLeaveBalance' of the current user in that expression

    if(Value(DataCardValue14.Text) > ............ , true , false)  please help fill the blanks using the collectd value


  • mdevaney Profile Picture
    29,991 Moderator on at

    @abieba 

     Your code here does not match mine.

     

     

    Collect(LeaveBalances,First(Filter('Leave Balance List','Staff Name'.Email = CurrentUserEmail)));

    Set(AnnualLeaveBalance,LeaveBalances.'Annual Leave Balance');
    Set(AnnualLeaveBalance,LeaveBalances.'Sick Leave Balance');
    Set(AnnualLeaveBalance,LeaveBalances.'Compassionate Leave Balance');

     


    You need to use 3 different variable names instead: AnnualLeaveBalance, SickLeaveBalance, CompassionateLeaveBalance

     

    Then, assuming DataCardValue14 refers to sick leave requested you would use:

     

    if(Value(DataCardValue14.Text) > sickLeaveBalance, true , false) 

     

    ---
    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

  • abieba Profile Picture
    129 on at

    Hi @mdevaney ,

    yeah i have edited the variables, saw it as soon as i sent the message.

     

    Now its showing an error 
     invalid arguement type, expectin a number value , i tried Value(AnnualLeaveBalance.Text) but still throws error

  • mdevaney Profile Picture
    29,991 Moderator on at

    @abieba 

    That means you are comparing a Number to something else (e.g. Text) in your If statement.  Try putting SickLeaveBalance inside a Value() function

     

    If you want to see what the collection looks like during troubleshooting just put it in a Data Table temporarily.  Similarly you can put the Set variables in Labels temporarily.  Just to see their values.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard