- 
                Notifications
    
You must be signed in to change notification settings  - Fork 146
 
SWQL Functions
        jakub-drzyzga-swi edited this page Dec 31, 2024 
        ·
        16 revisions
      
    SolarWinds Query Language supports a number of built-in functions that can be used in queries.
- 
IsNull(a, b)- Returnsaunless it isNULL, else returnsb. - 
Case when c then a else b end- Returnsaifcis true else returnsb. - 
UNION(q)- Adds the results of an additional queryqdirectly below the former, the number of columns must match between unioned queries 
- 
Abs(n)- Returns the absolute value ofn. - 
Ceiling(n)- Returns the smallest integer that is not less thann. - 
Floor(n)- Returns the largest integer that is not greater thann. - 
Round(n, p)- Returnsnrounded to thepdecimal places. 
- 
AddDate(u, n, d)- Returns a datenunits afterd, where the unit is specified by the first parameteru, which must be one of:'millisecond','second','minute','hour','day','week','month', or'year'. Theuargument must be a string literal. It can't be a query parameter or value derived from the data. - 
AddDay(n, d)- Returns a datendays afterd. - 
AddHour(n, d)- Returns a datenhours afterd. - 
AddMillisecond(n, d)- Returns a datenmilliseconds afterd. - 
AddMinute(n, d)- Returns a datenminutes afterd. - 
AddMonth(n, d)- Returns a datenmonths afterd. - 
AddSecond(n, d)- Returns a datenseconds afterd. - 
AddWeek(n, d)- Returns a datenweeks afterd. - 
AddYear(n, d)- Returns a datenyears afterd. - 
DateTime- Converts a string to a date. In most scenarios this conversion will happen automatically when needed by usage. - 
DateTrunc('datepart', 'd')- Where'datepart'is one of the following strings:'minute','hour','day','week','month','quarter','year'. Returns a date liked, but with all components more granular than'datepart'set to zero. - 
Day(d)- Returns the day of the month ofd. - 
DayDiff(a, b)- Returns the number of days (rounded to the nearest integer) thatbis later thana. - 
DayOfYear(d)- Returns the day of year ofd. January 1 is 1, February 1 is 32, etc. - 
Downsample(d, p)- Rounds the supplied timestampdto the defined time periodp. For example, a period of'00:15:00'would round to the nearest 15 minute time increment. Requires Orion 2018.3 or later. - 
GetDate()- Returns the current date in local time at the Orion server. - 
GetUtcDate()- Returns the current date and time in UTC. Please note possible issues. - 
Hour(d)- Returns the hour part ofd(in 24 hour format). - 
HourDiff(a, b)- Returns the number of hours (rounded to the nearest integer) thatbis later thana. - 
Millisecond(d)- Returns the millisecond part ofd. - 
MillisecondDiff(a, b)- Returns the number of milliseconds (rounded to the nearest integer) thatbis later thana. - 
Minute- Returns the minute part ofd. - 
MinuteDiff(a, b)- Returns the number of minutes (rounded to the nearest integer) thatbis later thana. - 
Month- Returns the month part ofd. January is 1. - 
MonthDiff(a, b)- Returns the number of months (rounded to the nearest integer) thatbis later thana. - 
QuarterOfYear(d)- Returns the quarter of the year that containsd. January, February, and March are 1; April, May, and June are 2; etc. - 
Second(d)- Returns the second part ofd. - 
SecondDiff(a, b)- Returns the number of seconds (rounded to the nearest integer) thatbis later thana. - 
ToLocal(d)- Convertsdto local time on the Orion server. - 
ToUtc- Convertsdto UTC time. - 
Week(d)- Returns the week number ofd. - 
WeekDay(d)- Returns the day of the week ofdas a number, with Sunday = 0, Monday = 1, ..., Saturday = 6. Available in Orion Platform 2016.1 and later. - 
WeekDiff(a, b)- Returns the number of weeks (rounded to the nearest integer) thatbis later thana. - 
Year(d)- Returns the year ofd. - 
YearDiff(a, b)- Returns the number of years (rounded to the nearest integer) thatbis later thana. 
Aggregate functions operate on a whole group of values at once. If a GROUP BY clause is present in the query, the aggregate function will operate on all values for each set of GROUP BY keys. If no GROUP BY clause is present, the aggregate function will operate on all values returned by the query.
- 
Avg(n)- Returns the average (arithmetic mean) of the values in the group. - 
Count(n)- Returns the number of non-NULLvalues in the group. - 
Max(n)- Returns the largest value in the group. - 
Min(n)- Returns the smallest value in the group. - 
Sum(n)- Returns the arithmetic sum of the values in the group. 
- 
ArrayContains(a, v)- Returns true if arrayacontains valuev. - 
ArrayLength(a)- Returns the number of elements in arraya. - 
ArrayValueAt(a, i)- Returns the array element at positioniin arraya, counting from zero. - 
SplitStringToArray(a)- Splits stringaon comma separators into an array of substrings. 
- 
Concat(a, b, c, ...)- Takes one or more arguments and returns a single string that is the concatenation of the values of the arguments. - 
EscapeSWISUriValue(a)- Returnsawith certain characters escaped. Intended for internal use only. - 
Length(s)- Returns the length of strings. - 
CharIndex(toFind, toSearch [, start])- Returns the position at whichtoFindoccurs withintoSearch(starting at positionstart, if provided) or zero iftoFindis not found. Supported since Orion Platform 2018.2 (NPM 12.3) and later. - 
SubString(s, start, length)- Returns a substring oflengthcharacters starting at positionstart(the first character is position 1). - 
Replace(expression, pattern, replacement)- Replaces all occurrences of a specified string (pattern) value inexpressionwith another string value (replacement). Supported since Orion Platform 2017.3 (NPM 12.2) and later. - 
ToLower(a)- Convertsato all lowercase. - 
ToUpper(a)- Convertsato all uppercase. - 
ToString(a)- Convertsato a string. In most scenarios this conversion will happen automatically when needed by usage. - 
UriEquals(a, b)- Returns true if SWIS Uriarefers to the same entity instance as SWIS Urib. 
- About SWIS
 - Connecting to SWIS
 - SWQL Functions
 - REST
 - PowerShell
 - Alerts
 - Groups
 - Creating custom properties
 - Poller Types
 - Network Performance Monitor
 - NetFlow Traffic Analyzer
 - Network Configuration Manager
 - IP Address Manager
 - Server & Application Monitor
 - Log Analyzer
 - Schema reference