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.  

ericonline
Level 10

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!