Home : DSORT
Q10741 - INFO: DSORT

DSORT returns the date of sorted values.

SYNTAX:

DSORT(VarNum, Offset, SortType, DateFormat,  Optional Grouping,  Optional GroupOffset)

VarNum:  The variable number to get the average for.

Offset/Date: Sets the offset of the sorted values for which the date should be returned.  For example, to get the date of the second highest value, a 2 (two) should be passed.  To get the third highest value, pass a 3 and so on.

SortType: Sets whether the data values are sorted Descending (Highest to Lowest) or Ascending (Lowest to Highest).  Valid settings are:

"DD" Date Descending
"DA" Date Ascending
"D" Value Descending
"A" Value Ascending

DateFormat:  Date Format to display.  Common formats:

Grouping/End Date OPTIONAL.  Used to set which dates to sort.  The default is all values in the date range of the report are sorted.  If the Grouping is a date literal string (i.e. "07/16/2004") or refers to a cell with a date in it, it is assumed to be the end date.  Otherwise, it is assumed to be a grouping. Common settings are:

"D" Daily
“M” Monthly
“Q” Quarterly
“Y” Yearly
Click here for available Grouping options

GroupOffset/Start Date OPTIONAL.  Used with the Grouping parameter to set which dates to sort. If the Grouping is a date literal string (i.e. "07/16/2004") or refers to a cell with a date in it, it is assumed to be the start date.  Otherwise,  it sets the number of Groups (set by the Grouping Parameter) to be added to set the dates.  See examples below.

NOTES:

This function is placed by checking the  Sort Values check box on the Sorting tab of Locate Daily Values.  The TOP N wizard report also utilizes this function.

When sorting by value ("D","A") the second sort criteria is ascending dates.  Therefore, when identical values are found the date of 1st (earliest by date) value will be shown first.  See examples.

EXAMPLES:

1. DSORT(81,1,"D","mm/dd/yy") 
For variable 81, returns the date of the 1st value of the sorted numbers.  The numbers are sorted from Highest to Lowest (“D”) and the date returned will be in mm/dd/yy format.

 

2. DSORT(2,5,"D", "mm/dd/yy") 
For variable 2,  returns the 5th value of the sorted numbers.  The numbers are sorted from Highest to Lowest (“D”) and the date returned will be in mm/dd/yy format.


3. DSORT(2,1,"A","mm/dd/yy","M",2) 
For variable 2, returns the lowest value of the sorted numbers for the second month of the report.  I.E. if the start date is Jan 1, 2000 this function would return the lowest value for the month of February 2000.

4. DSORT(2,1,"DD","mm/dd/yy hh:mm")
For variable 2,  returns the 1st Date of the entries sorted  by date.  The entries are sorted by date from latest date to earliest (“DD”) and the date returned will be in mm/dd/yy hh:mm format. 

In this example the folliowng table depicts all values in the report date range

Date V2
01/01/05 00:00   10
01/01/05 08:00   17
01/01/05 14:16   5
01/01/05 22:00   7
Returns "01/01/05 22:00"  

5. DSORT(2,3,"DA","mm/dd/yy hh:mm")
For variable 2,  returns the 3rd date of the entries sorted  by date.  The entries are sorted by date from earliest date to latest (“DA”) and the date returned will be in mm/dd/yy hh:mm format. 

In this example the folliowng table depicts all values in the report date range

Date V2
01/01/05 00:00   10
01/01/05 08:00   17
01/01/05 14:16   5
01/01/05 22:00   7
Returns " 01/01/05 14:16"

6. DSORT(2,3,"D","mm/dd/yy hh:mm","01/04/05","01/01/05")
For variable 2,  returns the 3rd highest value (D) of the entries defined by the start date (01/01/05) to the end date (01/04/05)

Sorted Values V2
01/01/05 00:00   10
01/01/05 08:00   17
01/04/05 22:00   7
01/03/05 14:16 5
Returns "01/04/05 22:00", use the DDV function to return the value at that time (7).

7. DSORT(2,1,"DA","mm/dd/yy hh:mm","01/04/05","01/01/05 7:15 AM")
For variable 2,  returns the 1st date/time at "01/01/05 7:15 AM" or later.

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 2/11/2008 10:08 PM.
Last Modified on 4/1/2010 2:18 PM.
Last Modified by Scott Dorner.
Article has been viewed 4849 times.
Rated 9 out of 10 based on 2 votes.
Print Article
Email Article