web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / displaying groupby(?) ...
Power Apps
Unanswered

displaying groupby(?) records in a data card

(0) ShareShare
ReportReport
Posted on by 22

I am wondering if this is even feasible to do, or if someone can suggest an alternative workaround for what I am trying to accomplish, but I have a contact database with duplicate people but with different data in certain fields. I have already filtered out the duplicates in the gallery to only display unique records based on email address, but when I go into the contact details, I want it to display the information for the entry selected (should be common across all "duplicate" records) but also have a card that displays certain fields that would be different across those "duplicate" records.

 

The code I used to remove duplicates in the gallery is

gregorykc_0-1671646498336.png

and the fields that would be different across the duplicate records are BuildingID and AfterHoursPriority, which are found in the AllContacts source.

I think I need to do a groupby at the gallery level and store it in a collection,

ClearCollect(AfrHrs,GroupBy(AllContacts,"EmailAddress","AfterHoursPriority"))

but then how do I ungroup it and display it at the contact details level inside a datacard, only showing the relevant fields in a table?

thanks!

Categories:
I have the same question (0)
  • AaronKnox Profile Picture
    514 Super User 2024 Season 1 on at

    Hi @gregorykc ,

    I'm not a big fan of the Distinct function because it is very limited as it only returns the distinct values in a single column table with the column name Result.  This does not work for complex scenarios.

     

    GroupBy, however, returns the distinct values as well as the entire table of corresponding records.  A common pattern is to wrap the GroupBy() with an AddColumns(), adding whatever columns you need by doing a Filter() or LookUp() from the table GroupBy creates.

    While this post I made a few days ago doesn't directly apply to your scenario, and is rather simple, it is an example of a GroupBy/AddColumns pattern that I use in situations where Distinct doesn't give me enough information to do additional data shaping:  Solved: Re: Charting mulitple series with AddColumns, Grou... - Power Platform Community (microsoft.com)

     

    To be of greater assistance I'd need more info on your database schema, but it looks you are on the right track and perhaps can just convert that Distinct gallery formula to a GroupBy.  Once you do, your gallery.selected will provide the GroupBy table to the rest of your app; just reference it like you would any other table.  For instance, to show the text column unitDescription from the first record of the group table, the formula is:

    First(Gallery.Selected._groupTable).unitDescriptionSLT

     

     

  • gregorykc Profile Picture
    22 on at

    Thanks for the advice @AaronKnox 

    I figured out an alternative method tipped off by your addcolumn nesting suggestion - I just created a gallery within the details page that did a search wrapped in a show columns to find all the duplicate records, and picked the columns to display the values I wanted

    Might not be the most efficient way, but my data set might be small enough that loading won't become an issue.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard