Skip to main content

Notifications

Power Platform Community / Forums / Building Power Apps / Create A Collection of...
Building Power Apps
Suggested answer

Create A Collection of Specific Values in a Record

Posted on by 33
Hi, On an app's gallery button within an item, how do I create a collection of the selected record where the value is = "Open" across multiple columns with choices of "Open" and "Closed"? 
 
Datasource is SharePoint with multiple columns, several of which are of the same choices of Open or Closed. Example:  Columns 1-7 are Choice = Open or Closed, but other columns are other choices, text, date. etc. 
 
The end result should be that when a user selects a specific record in the gallery (or gal_Test.selected) by pressing the "View Open Columns" button, then they should see what Columns have the value of "Open" in either a text label, another gallery, or a form.  
Categories:
  • PowerAutomatic Profile Picture
    PowerAutomatic 33 on at
    Create A Collection of Specific Values in a Record
    Carlos, Super quick fix. Thank you!
  • Create A Collection of Specific Values in a Record
    In this case, col_OpenAudits will have a single element (the record representing the selected item from the gallery); is that what you wanted to do? If that's the case, and assuming that 'Audit Questions_HM' is the SP list that has multiple choice columns with 'Open'/'Closed' values, then you can get the list of open columns using some expression like this one:
    ClearCollect(
        OpenColumnsCollection,
        Filter(
            [
                If(First(col_OpenAudits).Column1.Value = "Open", "Column1"),
                If(First(col_OpenAudits).Column2.Value = "Open", "Column2"),
                If(First(col_OpenAudits).Column3.Value = "Open", "Column3"),
                If(First(col_OpenAudits).Column4.Value = "Open", "Column4")
            ],
            Not IsBlank(Value)))
     
    Where 'Column1', 'Column2', 'Column3', 'Column4' will be the names of your columns.
     
    Hope this helps!
  • PowerAutomatic Profile Picture
    PowerAutomatic 33 on at
    Create A Collection of Specific Values in a Record
    Hi, 
     
    Thanks for staying with me on this. It is created via LookUp. Maybe that's the problem.
     
    ClearCollect(col_OpenAudits, LookUp('Audit Questions_HM',AuditName.Value = gal_Audits.Selected.'File Name'));
  • Create A Collection of Specific Values in a Record
    How is col_OpenAudits being created in your example? I don't understand exactly what the expression <<If(col_OpenAudits.HM_..._Finding.Value, "Open", "HM...Finding")>> is trying to do.
  • PowerAutomatic Profile Picture
    PowerAutomatic 33 on at
    Create A Collection of Specific Values in a Record
    Thank you Carlos. It almost works. I can't figure out this problem with it not accepting Value at the end of the table. I look up the collection, there is the table, I click on the table and there is the value, but power apps does not accept it. And of course, if Value is removed, it says can't compare table to text. I've tried variations based on your suggestion but no luck. It must be just one more thing to change or add. Maybe rename column or {Value: something something} but IDK. BTW, that column name is in the collection table, which matches the SharePoint field name in the URL. It won't accept the friendly column name in the code. 
     
     
  • Suggested answer
    Create A Collection of Specific Values in a Record
    You can use an expression similar to the following:
    ClearCollect(
        OpenColumnsCollection,
        Filter(
            [
                If(ThisItem.Column1.Value = "Open", "Column1"),
                If(ThisItem.Column2.Value = "Open", "Column2"),
                If(ThisItem.Column3.Value = "Open", "Column3"),
                If(ThisItem.Column4.Value = "Open", "Column4")
            ],
            Not IsBlank(Value)))
    In each of the If calls, if the column value is not open, then the result will be blank, so filtering those out should give you a collection with only the open ones.
    Hope this helps!

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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 141,157

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,414

Leaderboard