cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smpereira
New Member

sort with distinct

Is it possible to combine in one function DISTINCT and SORT? And how can it be possible to create a Collection using distinct?

8 REPLIES 8
mr-dang
Community Champion
Community Champion

You would have to nest it. 

 

The Items property of a gallery or dropdown would look like:

Sort(Distinct(datasource,column to find distinct records), column for sorting, ascending/descending)

 

You would collect what you want and the formula above would sort it after the fact.

 

That said, with the April 29 update to PowerApps, your datasource may not load entirely if you use both of those functions together since they have worked in "delegation."

Microsoft Employee
@8bitclassroom
TerjeF
Advocate III
Advocate III

I tried a lot, and come to this:

Sort(Distinct(Source,Column),Result)

bean
Continued Contributor
Continued Contributor

Sort(Distinct(Source,Column),Result) - Worked good for me. I additionally added the if statement  to switch the order.

 

Sort(Distinct(Source,Column),Result,If(SortDescending1, Ascending,Descending))

 

Thanks!

Where is the documentation for this? I cannot find how I should have known "Result" would just allow it to sort the column I performed the Distinct() operation on. It would not work with the column name. Required "Result" to be there.

@EdHansberry 

I found it in the 3rd sentence of the Distinct function documentation highlighted in bold  😋  In my opinion though it should just be in a column called value like everything else.  Why can't life be simple?

 

Link to Distinct function documentation

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-distinct

 

 

Screenshot:

 

Untitled.png

 

---
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."

Thank you! I was looking in the SORT documentation. 

@EdHansberry 

Ahhhhhh. That's why.  I understand now.  I think there's a few other functions that behave this way.  Split and Concatenate are two examples.  I can't recall if there's any others at this moment.

 

---
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."  

 

 

dnorena
New Member

For me the way that works is:

Distinct(Sort(Filter('Source';true).Column;Column;Ascending);Column)

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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