cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create a Gallery with non duplicates

Hi People.!

 

One question.

 

I have one Entity that have a lot of records. The information is the next

 

colum1    column2   column3

PC1          PACO        IVAN

PC2          PACO        MARTIN

PC3          IVAN         PACO

PC1          PACO        IVAN

PC2          PACO        MARTIN

 

I must show a gallery with all different records but colum1 without repetition.  Therefore I have 2 PC1 and 2 PC2, so I should to show one of each. 

 

I found the distinct functions but with this function i can show just one column. I need to show the 3 colums but not show duplicated for colum1    

 

thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Anonymous :

My method is similar to @mdevaney 's , the principle is to construct a new column/table that contains the value of Column1/2/3, and then deduplication. Finally, split the column again with split function.The difference of my method is to use concatenate and forall to build new table directly.

Set the gallery's items preperty to:

 

ForAll(
    Distinct(
        Concatenate(
            yourdatasource.column1,"##",yourdatasource.column2,"##",yourdatasource.column3),
            Result
    ),
    {
        column1: Last(FirstN(Split(Result,"##"),1)).Result,
        column2: Last(FirstN(Split(Result,"##"),2)).Result,
        column3: Last(FirstN(Split(Result,"##"),3)).Result
    }
)

 

Best Regards,

Bof

 

View solution in original post

2 REPLIES 2
mdevaney
Super User
Super User

@Anonymous 

Here's my take on the problem.  You could try to store the records with non-duplicate records inside a Collection 

 

ClearCollect(myUniqueRecords,
    DropColumns(
        AddColumns(
            Distinct(
                AddColumns(
                    your_datasource_name,
                    "CombinedColumns",Column1&";;"&Column2&";;"&Column3
                ),
                CombinedColumns
            ),
            "Column1",First(Split(Result,";;")).Result,
            "Column2",First(FirstN(Split(Result,";;"),2)).Result,
            "Column3",Last(Split(Result,";;")).Result
        ),
    "Column1"
    "Column2",
    "Column3"
    )
);

 


I built the solution using this example from my website.  If you're having trouble visualize the solution it might help
https://matthewdevaney.com/powerapps-collections-cookbook/unique-records-in-a-collection/

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

v-bofeng-msft
Community Support
Community Support

Hi @Anonymous :

My method is similar to @mdevaney 's , the principle is to construct a new column/table that contains the value of Column1/2/3, and then deduplication. Finally, split the column again with split function.The difference of my method is to use concatenate and forall to build new table directly.

Set the gallery's items preperty to:

 

ForAll(
    Distinct(
        Concatenate(
            yourdatasource.column1,"##",yourdatasource.column2,"##",yourdatasource.column3),
            Result
    ),
    {
        column1: Last(FirstN(Split(Result,"##"),1)).Result,
        column2: Last(FirstN(Split(Result,"##"),2)).Result,
        column3: Last(FirstN(Split(Result,"##"),3)).Result
    }
)

 

Best Regards,

Bof

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,121)