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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,699)