cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thunter
Level 8

SortByColumns Distinct

I am trying to Sort a Column that also is using the Distinct function. I have tried a couple different combinations to my formula. Any help would be appreciated. Thanks!

image99.jpgimage999.jpg

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
gsivasai
Level: Powered On

Re: SortByColumns Distinct

Hi @thunter,

 

How about you try this?- 

Also, make sure you got the right column name - year or Year. Try selection from the column names listed by the app while you are building the function.

 

SortByColumns(Distinct('[dbo].[wynne_incidents]',Year),"Result",Descending) 

 

Super User
Super User

Re: SortByColumns Distinct

Hi @thunter,

Distinct() creates a single column table and replaces the original column name with "Result".  Your formula would be 

SortByColumns(Distinct('[dbo].[wynne_incidents]',Year),"Result", Descending)

The syntax for the SortByColumns requires the column name in double quotes.  

3 REPLIES 3
Highlighted
gsivasai
Level: Powered On

Re: SortByColumns Distinct

Hi @thunter,

 

How about you try this?- 

Also, make sure you got the right column name - year or Year. Try selection from the column names listed by the app while you are building the function.

 

SortByColumns(Distinct('[dbo].[wynne_incidents]',Year),"Result",Descending) 

 

Super User
Super User

Re: SortByColumns Distinct

Hi @thunter,

Distinct() creates a single column table and replaces the original column name with "Result".  Your formula would be 

SortByColumns(Distinct('[dbo].[wynne_incidents]',Year),"Result", Descending)

The syntax for the SortByColumns requires the column name in double quotes.  

Super User
Super User

Re: SortByColumns Distinct

Man! Why can I not figure this out! Driving me bananas.

Data: Some of the ID's repeat, hence the need for Distinct records.

- Collection name: colData

- Example Record:
    - ID: 1234

    - Criteria1: string

    - Criteria2: string

    - Criteria3: string

    etc.

Gallery Items:

- IF user selects anything from Criteria1/2/3 dropdowns, display only DISTINCT records, grouped by ID, that meet Criteria 1/2/3

- IF Criteria 1/2/3 are Blank, show ALL records, grouped by ID

Tried so far:

//Labels in the Gallery don't like this one because only ThisItem.Result is available.

SortByColumns( Distinct( colData, ID ),"Result", Descending )
// This one also causes headaches for the labels in the Gallery. Seems like they need an IF statement to in order to function correctly.

If( And( IsBlank(criteria1.Selected.Value), IsBlank(criteria2.Selected.Value), IsBlank(criteria3.Selected.Value) ), GroupBy( colData, "ID", "GroupData" ), Sort( Filter(colData, criteria1.Selected.Value = criteria1 && criteria2.Selected.Value = criteria2&& criteria3.Selected.Value) = criteria3 ), ID, Ascending ) )

Considerations:

- Criteria 2/3 cascade based on Criteria 1.
Visual Aid:
image.png
Is this a challenging thing to do or am I missing something straightforward?
Thank you!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 30 members 4,231 guests
Please welcome our newest community members: