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 / Creating a collection ...
Power Apps
Answered

Creating a collection based on matching values of two other collections

(0) ShareShare
ReportReport
Posted on by 818
ClearCollect(
    PedidosSolicitados;
    Filter(
        Split(Trim(TextInput2.Text); " ");
        !IsBlank(Value)
    )
);;

ClearCollect(
    ValoresUnicos;
    Distinct(PedidosSolicitados; Value)
);;

 
//get matches stored in a Collection
ClearCollect(
    mySolution27a;
        ShowColumns(
            Filter(
                AddColumns(
                   PedidosSolicitados;
                  MatchFound;
                  If(!IsBlank(LookUp(ValoresUnicos;Value=PedidosSolicitados[@Value]));true;false)
            );
           MatchFound=true);
       Value)
)



This is my full code. From a textInput that can have for example Request1 Request2 Request1 (meaning Request1 repeated), it builds a collection with this in the Value column "Request1 Request2 Request1"

Second Collection will be "Request1 Request2", as it's getting distinct values.

I want a collection that only shows the repeated values, in this case it should be once "Request1"
 
In theory the final part of the code should acheive that, as per this guide: Find Matching Values Within Two Collections - Matthew Devaney; however this only creates a collection of "Request1 Request2 Request1"

Is is possible to create this collection?
Categories:
I have the same question (0)
  • Verified answer
    Ravi-Prajapati Profile Picture
    416 Super User 2025 Season 2 on at
    To get a collection that only contains the repeated values, you need to identify which values appear more than once in the PedidosSolicitados collection.
    Solution:
    Create PedidosSolicitados – This contains all values from TextInput2.Text, split into individual items.
    Create ValoresUnicos – This gets the distinct values.
    Create RepeatedValues – This filters only the values that appear more than once.
    Here’s how you can modify your approach:

    ClearCollect(
        PedidosSolicitados,
        Filter(
            Split(Trim(TextInput2.Text), " "),
            !IsBlank(Value)
        )
    );
    ClearCollect(
        ValoresUnicos,
        Distinct(PedidosSolicitados, Value)
    );
    // Collection that contains only repeated values
    ClearCollect(
        RepeatedValues,
        Filter(
            ValoresUnicos,
            CountIf(PedidosSolicitados, Value = ValoresUnicos[@Value]) > 1
        )
    );
    Explanation:
    The PedidosSolicitados collection holds the raw values.
    The ValoresUnicos collection extracts unique values.
    The RepeatedValues collection filters only those values that appear more than once by using CountIf.
    Expected Output:
    For input: "Request1 Request2 Request1"
    PedidosSolicitados:
    Value
    ------
    Request1
    Request2
    Request1
    ValoresUnicos:
    Value
    ------
    Request1
    Request2
    RepeatedValues:
    Value
    ------
    Request1
    This ensures you only get items that have been repeated at least once.
  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at
    Try this
    With(
       {
          _Data:
          Filter(
             Split(
                Trim(
                   TextInput2.Text
                ); 
                " "
             );
             !IsBlank(Value)
          )
       };
       ClearCollect(
          mySolution27a;
          Filter(
             GroupBy(
                _Data;
                Value;
                Grouped
             );
             CountRows(Grouped) > 1
          )
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
     
  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at
    You might also try what I posted - it only requires one collection (one-use collections just clog up resources)

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard