Skip to main content

Notifications

Community site session details

Community site session details

Session Id : XGQEHfGoFCjvfy4iFy/Riw
Power Apps - Building Power Apps
Answered

Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

Like (0) ShareShare
ReportReport
Posted on 2 Apr 2020 01:00:56 by 61

Hey guys, 

 

I am creating a check-in / check-out app on PowerApps that only allow users to check-in or check-out based on geolocation. I thought the easiest way would be creating a label, then creating a global variable "On Select" which would include the coordinates from a location. I would the same thing for the device's location which would include the location.latitude while creating the global variable for the device. 

 

In the end, I thought I could check if the label.text result would contain any results from the other label.text before inserting. Just to make sure the user is at the location. 

 

I already created both label texts which include the global variables. Does anyone know how I could check or compare if a label would contain strings from another label before checking in? I've done everything I could but with no success. I would appreciate it if someone could help me with this! 

 

Thank you,

  • reembkrey Profile Picture
    9 on 31 Oct 2022 at 12:58:04
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    Hello Everyone

    I want to create a flow to send a response for all received inquiries that match the inquiry in an excel sheet ex.

    Inquiry

    Response

    what are your working times

    8:00 AM-5:00 PM

    registration requirement

    ID, Passport

     

     

     

    check the flow for more details

    reembkrey_0-1667220581235.png

    reembkrey_1-1667220612155.png

    reembkrey_2-1667220670150.png

     

    reembkrey_3-1667220688865.png

     

     

    last(split(first(split(outputs('Html_to_text')?['body'],' Regards')),'Hi '))
    this is what I used to get the text in between to compare it in excel, and the flow works the problem is if the greeting is not Hi or something else written in the last not Regards as I wrote in the split, and let's say the email is "just want to check your working time" the filter will not work and I will get no reply

     

    Thank you in advance

  • reembkrey Profile Picture
    9 on 31 Oct 2022 at 12:43:38
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    Hi guys

    I hope you can help me too ,power automate I need an expression to help me compare a text in an email and a text in an excel sheet I used (Contains ) for the action( list a row in a table )in the( filter query part) yet it doesn't compare if the sentence is more than the one in the excel

    for example, check this email below

    Hi

    what is your working time?

    Regards

     

    so the flow is to reply to this email after comparing and filtring the excel and then get the column next to it, so I need to answer any email containing working time 

  • rafaelbenicio Profile Picture
    61 on 14 Apr 2020 at 15:33:31
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    Hi @v-xida-msft , 

     

    Sorry, It took me a while to answer because I've been testing with some users. I am happy to say your expression worked well. The only thing is I am having issues right now is my check-out button. Why does my check-out button is creating a new line for some users when they check out? Side note: That doesn't happen to me. Here is a screenshot of that: 

     

    Screen Shot 2020-04-14 at 9.17.54 AM.png

     

    Here is my check out button expression 'On Select'. Is there anything wrong with it?

     

     

    Refresh(CheckInCheckOut);
    If(
     !IsBlank(LookUp(CheckInCheckOut,PersonalEmail=Office365Users.MyProfile().Mail && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy"))) 
     &&
     Abs(Value(FALatLabel.Text)- Value(DeviceLatLabel.Text)) <= 0.0005000
     && 
     Abs(Value(FALongLabel.Text) - Value(DeviceLogLabel.Text)) <= 0.0005000,
    
     Patch(
     CheckInCheckOut,
     LookUp(CheckInCheckOut,PersonalEmail=Office365Users.MyProfile().Mail && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy")),
     {
     Check_x0020_Out: Now()
     }
     );Navigate(Screen3,ScreenTransition.Fade)
    ,Notify("You are not at the destination location, please go the destination location and check out", NotificationType.Error)
    )

     

     Thank you so much! 

    Rafael Benicio

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 03 Apr 2020 at 01:48:46
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    Here is an example that clearly shows that the comparison is done for the first 6 digits. 

    LatLong.JPG

    Here is the expression I used to check if Device 1 is onsite or not: 

    If(
     Left(
     Label_LocationLatitude.Text,
     Find(
     ".",
     Label_LocationLatitude.Text
     ) + 3
     ) = Left(
     Label_Device1Latitude.Text,
     Find(
     ".",
     Label_Device1Latitude.Text
     ) + 3
     ) && Left(
     Label_LocationLongitude.Text,
     Find(
     ".",
     Label_LocationLongitude.Text
     ) - 1
     ) = Left(
     Label_Device1Longitude.Text,
     Find(
     ".",
     Label_Device1Longitude.Text
     ) - 1
     ),
     "Onsite",
     "Not onsite yet"
    )

    Here is the expression I used to check if Device 2 is onsite or not:

    If(
     Left(
     Label_LocationLatitude.Text,
     Find(
     ".",
     Label_LocationLatitude.Text
     ) + 3
     ) = Left(
     Label_Device2Latitude.Text,
     Find(
     ".",
     Label_Device2Latitude.Text
     ) + 3
     ) && Left(
     Label_LocationLongitude.Text,
     Find(
     ".",
     Label_LocationLongitude.Text
     ) + 3
     ) = Left(
     Label_Device2Longitude.Text,
     Find(
     ".",
     Label_Device2Longitude.Text
     ) + 3
     ),
     "Onsite",
     "Not onsite yet"
    )

     

    Hope this helps. 

     

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

     

    Thanks!
    Hardit Bhatia
    https://thepoweraddict.com

  • Verified answer
    v-xida-msft Profile Picture
    on 03 Apr 2020 at 01:40:57
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    Hi @rafaelbenicio ,

    Do you want to compare your device Latitude value and Longitude value with a range of your destination Latitude value and Longitude value?

     

    Currently, within PowerApps, there is no way or function supported to check if a device's Latitude value and Longitude value is within a range of your destination Latitude value and Longitude value.

     

    As an alternative solution, you could assume that if the value difference between the destination Log/Lat value and the device log/Lat value is not more than 0.2, they represents same location, so you could modify your formula as below:

    If(
     Abs(Value(DestinationLatLabel.Text)- Value(DeviceLat.Text)) <= 0.2
     && 
     Abs(Value(DestinationLongLabel.Text) - Value(DeviceLong.Text)) <= 0.2,
     Patch(
     CheckInCheckOut, 
     Defaults(CheckInCheckOut),
     {
     Title: "Check In&Out",
     PersonalName: User().FullName,
     PersonalEmail: User().Email,
     Check_x0020_In: Now()
     }
     ),
     Notify("You are not at the destination location, please go the destination location and check in", NotificationType.Error)
    )

     

    Please note that the 0.2 gap point is based on your scenario, you could change the allowed difference value range to other values, e.g. 0.3 or 0.5 or 0.6, ....

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards, 

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 03 Apr 2020 at 00:27:14
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)
    That's what I shared with you and told you to change the -1 to +3. Please go through all of my previous posts and if you still dont get it, I can repost the formula here.
  • rafaelbenicio Profile Picture
    61 on 02 Apr 2020 at 23:36:33
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    I have but I don't want to compare things before the "." decimal place. I want to compare the first 6 digits. 😉 

    Thanks

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 02 Apr 2020 at 23:34:15
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)
    I am talking about this one, which I am not sure you tried:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Comparing-two-text-labels-before-with-Contains-function-before/m-p/513946/highlight/true#M156638

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

    Thanks!
    Hardit Bhatia
    The Power Addict
    https://thepoweraddict.com
  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 02 Apr 2020 at 23:32:05
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)
    My original suggested formula was not using StartsWith. Did you try that?
  • rafaelbenicio Profile Picture
    61 on 02 Apr 2020 at 21:08:22
    Re: Comparing two text labels before with Contains function before inserting data on SP list (Geolocation)

    Honestly, 

     

    It just looks like the StartWith expression is not working. My iPhone is getting the proper location, but it looks like the logic is wrong. 

     

    Do we have a better way of doing that through another expression? Thank you!

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard