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 / Compare list of Values...
Power Apps
Unanswered

Compare list of Values to columns in a Record

(0) ShareShare
ReportReport
Posted on by 4

I'm trying to find the best way to check a number of columns within a record against a list of values and return a boolean response.

 

The IDXApprovChoice columns can either be blank or contain other integers.

Approval ChoiceApproval Choice

 

 

 

The values in the column then need to be checked against the approvals ID's. This list is dynamic, the number of options can change. While only showing 4 entries there are currently 15 unique values in the list.

Choices ListChoices List

I have two collections, Approvals, the responses, and Choices, checking integers. I need is to look through the Approvals record and compare it to the Choices list. If any value is in the Choices return true else false.

 

Any thought on best and most efficient direction on how to solve?

 

Many Thanks in advance.

 

 

 

 

 

 

 

 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,452 Super User 2025 Season 2 on at

    Hi @Phil606 

     

    Before I answer, quick question.

    Where are you writing the boolean value after you calculuate it?

     

    Essentially you have

    Column1 Column2 Column3

     

    I am assuming you want something like in your collection

     

    Column1: Value

    Column1Boolean: Value

     

    Just making this up, but need to understand. Also, is this a Triggered calculation? Like how does the data load etc?

     

     

  • Phil606 Profile Picture
    4 on at

    @FLMike 

    Thanks for the response. I hope the following provides some additional details on what I'm doing. As for the reason for the boolean? It is an unlock function. I need to check if just one of 10 options is in any of 6 response options. 

    If a value shows up in the Approval Choice, and it is only one, for the selected record,  it's valid and it allows access to another table.

    The following is what I currently have:

     

     

    // Collect active and approved Approval Choices Index field only
    // Loads in App.OnStart as choices unlikely to change when app running.
    ClearCollect(
     colApprovedChoices,
     ShowColumns(
     Filter(
     Choices',
     And(
     Choices = 1,
     Status = 1
     )
     ),
     IDXApprvChoice
     )
    );
    // Runs OnVisible. Check if record is valid, and approved.
    // Collect Approved Record from Approvals table. Only Choices columns required.
    ClearCollect(
     colApprovalsCheck,
     ShowColumns( // Produces Record with 2 columns: Name: IDXApprvChoiceN, Value: Number
     LookUp(
     'Approvals',
     IDXRef = varNewApproval.IDXRefID //Current record to be checked
     ),
     IDXApprvChoice1,
     IDXApprvChoice2,
     IDXApprvChoice3,
     IDXApprvChoice4,
     IDXApprvChoice5,
     IDXApprvChoice6
     )
    );
    // Concat columns to single record. Then split into single column
    ClearCollect(
     colApprovalsCheck,
     ForAll(
     Split(
     Concat(
     colApprovalsCheck,
     ThisRecord.IDXApprvChoice1 & ";" & 
     ThisRecord.IDXApprvChoice2 & ";" &
     ThisRecord.IDXApprvChoice3 & ";" &
     ThisRecord.IDXApprvChoice4 & ";" &
     ThisRecord.IDXApprvChoice5 & ";" &
     ThisRecord.IDXApprvChoice6
     ),
     ";"
     ),
     {IDApprv: Value}
     )
    );
    // Test output to check if valid choice in selected record.
    //
    // Following is for testing result is valid and works
    Text = If(!IsBlank(LookUp(colApprovalsCheck,IDApprv in colApprovedChoices)),true,false)

     

     

    It's a bit of a rats nest, but it works and returns true/false.

    Interestingly enough the ShowColumns() does return a record with the information as required:

     

     

    Name Value
    IDXApprvChoice1
    IDXApprvChoice2
    IDXApprvChoice3
    IDXApprvChoice4
    IDXApprvChoice5
    IDXApprvChoice6 16

     

     

    But I cannot workout how to extract the Value. In the collection it returns it as a single row.

    I'm sure it can be refined, so any help is appreciated. 

     

     

  • Michael E. Gernaey Profile Picture
    53,452 Super User 2025 Season 2 on at

    Hi @Phil606 

     

    Do you mean for instance the value 16? In your 

    colApprovalsCheck

    collection??

     

    Name Value
    IDXApprvChoice1
    IDXApprvChoice2
    IDXApprvChoice3
    IDXApprvChoice4
    IDXApprvChoice5
    IDXApprvChoice6 16

     

    So are you trying to get to this I believe

    ColumnName, MatchedValue, UnLock or not

     

    So I took yours and did this by change your { } to add an UnLock field

    Name, Value, UnLock

     

    {IDApprv: Value, UnLock: If(!IsBlank(Value), true, false)}
    
    

     


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Phil606 Profile Picture
    4 on at

    @FLMike 

    The value 16 just happened to be in the record I'd selected.

    I hope the following helps with what I'm trying to improve on. I know I cannot use With() as this is a closed box and I need the result to be available within the selected user screen/page.

    The process runs as follows.

    1. The collection colApprovedChoices is populated during App.OnStart. It filters the Choice list and holds only the IDXApprvChoice. The current approved values are: 2, 6, 12, 16, 18, 19, 20 ,21, 22 and 25.
    2. On a user screen a Record is selected from a gallery, varNewApproval. This has details of their tasks which have been submitted.
    3. Submitted task are reviewed by others and dependant on the decision will either approve, reject or pass up the management chain. These outputs are recorded in the columns IDXApprvChoice in a separate table which records those decisions. The records being linked with a key field.
      1. Any of the IDXApprvChoice columns can hold a value or not, so there can be up to 6 values being recorded or just the one.
      2. At any stage within the approval process a colApprovedChoice value could be given and the task returned.
      3. The task is returned with a notification as either approved, requiring more information, true or rejected, false.
      4. Currently I conacat all 6 columns IDXApprvChoice from the selected record in the Approvals list and then Split that result and output as a list to the collection colApprovedCheck. This effectively pivots the columns and allows comparison between colApprovedChoice and colApprovedCheck.
    4. Within the users tasks screen there is a section which is locked when the task is submitted for review. It only becomes unlocked when a value in colApprovedCheck equals a value in colApprovedChoice. This comparison can only be true or false.

    The following runs on the tasking screen OnVisible, though I've not included the additional checking code for brevity. 

     

     

    // Runs OnVisible. Check if record is valid, and approved.
    // Collect Approved Record from Approvals table. Only Choices columns required.
    ClearCollect(
     colApprovalsCheck,
     ShowColumns( // Produces Record with 2 columns: Name: IDXApprvChoiceN, Value: Number
     LookUp(
     'Approvals',
     IDXRef = varNewApproval.IDXRefID //Current record to be checked
     ),
     IDXApprvChoice1,
     IDXApprvChoice2,
     IDXApprvChoice3,
     IDXApprvChoice4,
     IDXApprvChoice5,
     IDXApprvChoice6
     )
    );
    // Concat columns to single record. Then split into single column
    ClearCollect(
     colApprovalsCheck,
     ForAll(
     Split(
     Concat(
     colApprovalsCheck,
     ThisRecord.IDXApprvChoice1 & ";" & 
     ThisRecord.IDXApprvChoice2 & ";" &
     ThisRecord.IDXApprvChoice3 & ";" &
     ThisRecord.IDXApprvChoice4 & ";" &
     ThisRecord.IDXApprvChoice5 & ";" &
     ThisRecord.IDXApprvChoice6
     ),
     ";"
     ),
     {IDApprv: Value}
     )
    );

     

     

    As a validation check I have a text box which contains the code that appears at the end of the main section.

     If(!IsBlank(LookUp(colApprovalsCheck,IDApprv in colApprovedChoices)),true,false) 

    The Name/ Value table is the output from the ShowColumns which produces a record, in my case, pivots the data as required, but appears it is inaccessible to output the results as displayed. Is there a way to extract the record it creates?

    Again, many thanks.

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 739 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 268

Last 30 days Overall leaderboard