Is there a way to ORDERBY() using multiple sort columns?

Hi everyone, I love this ORDERBY() expression, and it’s already extremely useful, however I wanted to enhance its usefulness even more by adding another column condition to the end (like Excels top-down approach to columnsort). Is this possible to achieve by changing my expression ever so slightly?

My current expression (being used in an attachment template) is as follows…
<<Start: ORDERBY(FILTER(“Timesheet”, AND( [Status] = “COMPLETE”, [Date] >= [From], [Date] <= [To])), [Machine])>>

What I would like to do is sort by [Machine], as well as another column (e.g Type / Date / Name etc).
Hopefully this is doable, and if so doesn’t require a lot of tweaking.

Thanks for reading guys.

Solved Solved
0 4 1,395
1 ACCEPTED SOLUTION

That’s correct @Dario. The expression I have given is just an example so that you can fit it into yourself as I’m unaware of your table schema.

ORDERBY(
	FILTER(
		"Timesheet", // Filtered tablename
		AND(
			[Status] = "COMPLETE",
			[Date] >= [From], [Date] <= [To]
		) // Filter condition
	),
	[Machine], // Ordering column
	TRUE, // TRUE: Ascending | FALSE: Descending
	[Date], // Ordering column
	([Date]<=TODAY()+10,[Date]>=TODAY()+10), // TRUE/FALSE statement
	[Type], // Ordering column
	(CONTAINS[Type],"Some Type") // TRUE/FALSE statement
)

View solution in original post

4 REPLIES 4

<<Start: ORDERBY(FILTER(“Timesheet”, AND( [Status] = “COMPLETE”, [Date] >= [From], [Date] <= [To])), [Machine],TRUE,[Date],([Date]<=TODAY()+10,[Date]>=TODAY()+10),[Type],(CONTAINS[Type],"Some Type"))>>

Not what I was expecting, but thanks. I think this solution you provided is where it refers to the section in Steves link that says ‘Rows may be sorted by multiple sort keys: each additional sort key expression must be separated from the previous by an intervening descending-order? argument.’ right?

That’s correct @Dario. The expression I have given is just an example so that you can fit it into yourself as I’m unaware of your table schema.

ORDERBY(
	FILTER(
		"Timesheet", // Filtered tablename
		AND(
			[Status] = "COMPLETE",
			[Date] >= [From], [Date] <= [To]
		) // Filter condition
	),
	[Machine], // Ordering column
	TRUE, // TRUE: Ascending | FALSE: Descending
	[Date], // Ordering column
	([Date]<=TODAY()+10,[Date]>=TODAY()+10), // TRUE/FALSE statement
	[Type], // Ordering column
	(CONTAINS[Type],"Some Type") // TRUE/FALSE statement
)

Steve
Platinum 4
Platinum 4
Top Labels in this Space