Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Compare/Match/Read a column in a table with another

(0) ShareShare
ReportReport
Posted on by

Hi Guys, 

I have a column of Codes, which has 6 digits stored as TEXT field in a Collection 'colAllCodes'.

I have a Gallery of Codes 6 digits stored as TEXT field, requested to be Added to a SharePoint List.

Before I add to the SharePoint List, I want to check if the first FOUR digits only of the Requested Codes exist in the first four digits of colAllCodes.

If any of the Requested Codes first four characters match with the first four characters of colAllCodes,  Set(varShowAoA, false) else Set(varShowAoA, true).

In the following case, 3314 matches but 7010 do not match, so the function outcome should be Set(varShowAoA, true)

 

Requested Codes Gallery

Codes

331412
701012

 

Collection colAllCodes

Value

422010
422060
432220
439050
773012
331411
331412
521093
351011
477312

 

Hope my query is clear, thanks in anticipation for your assistance. 

Laik

  • Laik Profile Picture
    on at
    Re: Compare/Match/Read a column in a table with another

    Thanks Warren ... That did worked fine as well 

  • Verified answer
    WarrenBelz Profile Picture
    146,587 Most Valuable Professional on at
    Re: Compare/Match/Read a column in a table with another

    @Laik ,

    I am still a bit perplexed how the code you posted gets the result you described, however you can condense as below and not have collections hanging around

    With(
     {
     _AllCodes:
     Distinct(
     colAllCodesWDuplicates,
     Left(Value, 4)
     ),
     _RequestCode:
     Left(
     galRequested.Selected.ISICCode.Value, 
     4
     )
     },
     With(
     {
     _Matched:
     ForAll(
     _RequestCode, 
     Value exactin _AllCodes
     )
     },
     Set(
     varShowAoA, 
     CountRows(
     Filter(
     _Matched,
     !Value
     )
     ) > 0
     )
     )
    )

     

  • Laik Profile Picture
    on at
    Re: Compare/Match/Read a column in a table with another

    I completely agree that you gave me the direction and the code to match the logic, I am very much happy to accept your solution, which I had did in the first code itself.. I will do it here as well ! 

    You are awesome 

  • Verified answer
    WarrenBelz Profile Picture
    146,587 Most Valuable Professional on at
    Re: Compare/Match/Read a column in a table with another

    @Laik ,

    You might have a look at some of the suggestions posted and how they match what you were asking. I am wondering how what you have now actually does the job you described, but if it works, that is good.

  • Verified answer
    Laik Profile Picture
    on at
    Re: Compare/Match/Read a column in a table with another

    Hi Warren,

    Thanks for all your support and patience.

    However, for some reason, your revised code doesn't seem to work when there two or more codes match with the codes in colAllCodes. I played around with your revised code and tried a different way and fortunately, it worked for me, I created three collections of only 4 first four digits, first one with all codes, 2nd collection with the requested codes to add and the third one for the codes that matched exactly in the above two collections.

       

    ClearCollect(colAllCodes,Distinct(colAllCodesWDuplicates,Left(Value, 4)));
    ClearCollect(colRequestCode, Left(galRequested.Selected.ISICCode.Value, 4));
    ClearCollect(colMatched, ForAll(colRequestCode, Value exactin colAllCodes));
    Set(varShowAoA, CountRows(Filter(colMatched, Value=false)) > 0);

    and fortunately it worked exactly the way I wanted.

    Thanks once again...

     

  • WarrenBelz Profile Picture
    146,587 Most Valuable Professional on at
    Re: Compare/Match/Read a column in a table with another

    @Laik ,

    .So if everything other than all items in the gallery having a match , we are back to does not equal the row count of the gallery in the last code I posted.

    CountRows(
     Ungroup(
     ForAll(
     Gal As _Match,
     LookUp(
     Codes,
     Col4 = _Match.Value
     )
     ),
     "Value"
     )
    ) <> CountRows(_Gal)

    So if the total number of matches of items in the gallery to the collection does not equal the total number of items in the gallery (in other words they do not all match), the result is true

  • Laik Profile Picture
    on at
    Re: Compare/Match/Read a column in a table with another

    Nothing Matches (both the requested codes do not match with any code in colAllCodes) - Set(varShowAoA, true)

    At least one, but not all match (at least one requested code match with any code in colAllCodes, but if the second requested code do not match or there is a code in the galrequest which does have a match in colAllCodes) - Set(varShowAoA, true)

    All match (each and every (ALL) requested code matches with the colAllCodes) - Set(varShowAoA, false)

    Thanks for your help Warren.

     

     

  • WarrenBelz Profile Picture
    146,587 Most Valuable Professional on at
    Re: Compare/Match/Read a column in a table with another

    @Laik ,

    I have read your posts several times and to be honest still do not fully grasp exactly what you are trying to achieve, however as I noted of the three possibilities I can get for you:

    • Nothing matches 
    • At least one, but not all match
    • All match

    Which one should set the variable to true (or false if it is one)

  • Laik Profile Picture
    on at
    Re: Compare/Match/Read a column in a table with another

    Thanks for your help ... but that does not resolve my issue. Don't know what to do!

  • WarrenBelz Profile Picture
    146,587 Most Valuable Professional on at
    Re: Compare/Match/Read a column in a table with another

    @Laik ,

    You cannot set a variable inside a ForAll statement if that is what you are asking. All I can deal with are the three end possibilities I listed and set true or false based on the outcome of two of these 

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,587 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard