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 / Best way to make multi...
Power Apps
Unanswered

Best way to make multiple columns in collection the uses Distinct

(0) ShareShare
ReportReport
Posted on by 135

So I have a collection, and I wanted to make a collection of these items because it is going to be used in a gallery. I thought this was going to make several columns in the collection. However, I realised that using distinct is going to return a table. So, I can no longer use the results in a label inside the gallery. I would appreciate any idea, and help

ClearCollect(
 disPracTeam,
 Distinct(
 'dbJS.ISTaxes',
 isTaxPracTeam
 )

)*/


ClearCollect(
 disPracTeam,
 {
 title: Distinct(
 'dbJS.ISTaxes',
 isTaxPracTeam),
 
 grade: Distinct(
 SortByColumns(
 Filter(
 'dbJS.dealsStaffMngrUps',
 !IsBlank(GlobalGradeName)
 ),
 "crfb2_globalgradename",
 Ascending
 ),
 GlobalGradeName
),
 location: Distinct(
 SortByColumns(
 Filter(
 'dbJS.dealsStaffMngrUps',
 !IsBlank(OfficeLocationCity)
 ),
 "crfb2_officelocationcity",
 Ascending
 ),
 OfficeLocationCity
),
 name: Distinct(
 SortByColumns(
 Filter(
 'dbJS.dealsStaffMngrUps',
 !IsBlank(Name)
 ),
 "crfb2_name",
 Ascending
 ),
 Name
)

 }

);

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,779 Most Valuable Professional on at

    Hi @Jeffclark ,

    Firstly, can you please post your code in Text - below is OCR'd so watch spelling - you need to use GroupBy and then "get the columns back"

    ClearCollect(
     disPracTeam,
     {
     grade: 
     SortByColumns(
     AddColumns(
     GroupBy(
     Filter(
     'dbDS.dealsStaffMngrUps',
     !IsBlank(GlobalGradeName)
     ),
     "GlobalGradeName",
     "Data"
     ),
     "Column1Name",
     First(Data).Column1Name,
     "Column2Name",
     First(Data).Column2Name
     ),
     GlobalGradeName
     ),
     location: . . . .

     

    Please click Accept as solution 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 Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Jeffclark Profile Picture
    135 on at

    @WarrenBelz I have updated it to include the full code in text if you still wanted to see it, but I will check out your solution.

  • Jeffclark Profile Picture
    135 on at

    @WarrenBelz So, I may need a little more explanation on this if you do not mind. I guess I am not understanding the the "data" or column1 and column2 are referring to? 

    ClearCollect(
     disPracTeam,
     {
     grade: 
     SortByColumns(
     AddColumns(
     GroupBy(
     Filter(
     'dbJS.dealsStaffMngrUps',
     !IsBlank(GlobalGradeName)
     ),
     "GlobalGradeName",
     "Data"
     ),
     "Column1Name",
     First(Data).Column1Name,
     "Column2Name",
     First(Data).Column2Name
     ),
     GlobalGradeName
     )
     }
    )

     

  • WarrenBelz Profile Picture
    155,779 Most Valuable Professional on at

    Hi @Jeffclark ,

    Firstly, you might have a read of the GroupBy guide. You can call Data whatever you want - it is a table field with all the columns and rows (except the grouped column) of the records matching the grouped column. Column1 and Column2 (and 3/4/5 etc) are the columns you need to "get back" as they are sitting in the Data Table - you can however only get back one field value in each (I have used the first one) as you need a single value for the added column.

     

    Please click Accept as solution 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 Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Jeffclark Profile Picture
    135 on at

    @WarrenBelz 

    Something like this?

     

    ClearCollect(
     disPracTeam,
     {
     grade: 
     SortByColumns(
     AddColumns(
     GroupBy(
     Filter(
     'dbJS.dealsStaffMngrUps',
     !IsBlank(GlobalGradeName)
     ),
     "crfb2_globalgradename",
     "globalGrade"
     ),
     "global",
     First(globalGrade).global
     ),
     "crfb2_globalgradename",
     Ascending
     )
     })

     

     

  • WarrenBelz Profile Picture
    155,779 Most Valuable Professional on at

    Hi @Jeffclark ,

    Yep - that is about it as long as you have all your list and field references correct.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard