docs.intersystems.com
InterSystems IRIS Data Platform 2019.2  /  InterSystems MDX Reference

InterSystems MDX Reference
%FIRST
Previous section           Next section
InterSystems: The power behind what matters   
Search:  


Returns the value of the given measure (or other numeric expression) evaluated for the first non-empty member of a set. This function is an InterSystems extension to MDX.
Returned Type
This function returns a number.
Syntax and Details
%FIRST(set_expression, optional_numeric_expression)
Where:
The %FIRST function returns the first non-missing value evaluated for each member of the given set.
Example
For reference, the following query shows patients with asthma, grouped by birth decade:
SELECT MEASURES.[%Count] ON 0, birthd.decade.MEMBERS ON 1 FROM patients WHERE diagd.asthma
 
                             Patient Count
 1 1910s                                  *
 2 1920s                                  *
 3 1930s                                  1
 4 1940s                                  9
 5 1950s                                  8
 6 1960s                                 11
 7 1970s                                 12
 8 1980s                                 14
 9 1990s                                 11
10 2000s                                 14
11 2010s                                  4
The following query uses %FIRST to get the first non-empty set of patients from the preceding set:
SELECT MEASURES.[%Count] ON 0, %FIRST(birthd.decade.MEMBERS) ON 1 FROM patients WHERE diagd.asthma
 
                             Patient Count
FIRST                                     1
See Also


Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-08-22 06:48:58