The macros listed below can be used in scripts as well as in calculated columns, alert rules, rules, etc.
The first column in the table shows the name or signature of the macro. The next five columns are descriptions of the parameters that the macro can receive. The Returns column describes what the macro returns when executed and the Example column provides an example of how to use the macro.
| Macro | Parameter1 | Parameter2 | Parameter3 | Parameter4 | Parameter5 | Returns | Example | Comment |
|---|---|---|---|---|---|---|---|---|
| Number(string x) | string that should be converted to number | number if successfully converted, or null if not | return Number("435,45"); | https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings | ||||
| ToObject(string x) | string that should be converted to object | string converted to object | return ToObject("Hello World!"); | |||||
| ToObject(decimal x) | number that should be converted to object | number converted to object | return ToObject("435,45"); | |||||
| Date(string x) | string that should be converted to date | date if successfully parsed, or null if not | return Date("2022-12-20"); | |||||
| Date(string x, string format) | string that should be converted to date | string that represents exact date format of the first first parameter | date if successfully parsed, or null if not | return Date("12/12/2022", "dd/MM/yyyy"); | ||||
| Date(int? year, int? month, int? day) | number representing year | number representing month | number representing day | date if all parameters are not null, else null | return Date(2022, 4, 25); | |||
| Day(DateTime? date) | date from which day will be extracted | number representing day from the date | var date = Date("2022-12-20"); return Day(date); | |||||
| DayOfWeek(DateTime? date) | date from which day of the week will be extracted | string representing day of the week from the date | var date = Date("2022-12-20"); return DayOfWeek(date); | |||||
| DayOfYear(DateTime? date) | date from which day of the year will be extracted | number representing day of the year from the date | var date = Date("2022-12-20"); return DayOfYear(date); | |||||
| Month(DateTime? date) | date from which month will be extracted | number representing month from the date | var date = Date("2022-12-20"); return Month(date); | |||||
| Year(DateTime? date) | date from which year will be extracted | number representing year from the date | var date = Date("2022-12-20"); return Year(date); | |||||
| Today() | today's date | return Today(); | ||||||
| MinDate() | smallest possible date | return MinDate(); | ||||||
| MaxDate() | largest possible date | return MaxDate(); | ||||||
| Now() | current date with time component | return Now(); | ||||||
| AddDays(DateTime? date, decimal? days) | date upon which days will be added | number of days to add, can be negative value | incremented date if all parameters are provided, or null if not | var date = Date("2022-12-20"); return AddDays(date, -1); | ||||
| AddMonths(DateTime? date, int? months); | date upon which months will be added | number of months to add, can be negative value | incremented date if all parameters are provided, or null if not | var date = Date("2022-12-20"); return AddMonths(date, 2); | ||||
| AddYears(DateTime? date, int? years); | date upon which years will be added | number of years to add, can be negative value | incremented date if all parameters are provided, or null if not | var date = Date("2022-12-20"); return AddYears(date, 1); | ||||
| AddHours(DateTime? date, int? hours); | date upon which hours will be added | number of hours to add, can be negative value | incremented date if all parameters are provided, or null if not | var date = Date("2022-12-20 13:40:00", "yyyy-MM-dd HH:mm:ss"); return AddHours(date,4); | ||||
| ConvertUTCTime(DateTime? date, string timeZone) | UTC date | string representing destination time zone | date and time in the destination time zone, or null if conversion failed | var date = Date("2022-12-20 13:40:00", "yyyy-MM-dd HH:mm:ss"); return ConvertUTCTime(date,"Eastern Standard Time"); | https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11 | |||
| AddBusinessDays(DateTime? date, decimal? offset) | date upon which business days will be added | number of business days to add, can be negative value | incremented date if all parameters are provided, or null if not | var date = Date("2022-12-20"); return AddBusinessDays(date, -1); | ||||
| TotalMilliseconds(DateTime? startDate, DateTime? endDate) | date representing starting point to count milliseconds | date representing end point to count milliseconds | number representing total milliseconds between startDate and endDate | var startDate = Date("2022-12-20"); var endDate = Date("2022-12-25"); return TotalMilliseconds(startDate, endDate); | ||||
| TotalSeconds(DateTime? startDate, DateTime? endDate) | date representing starting point to count seconds | date representing end point to count seconds | number representing total seconds between startDate and endDate | var startDate = Date("2022-12-20"); var endDate = Date("2022-12-25"); return TotalSeconds(startDate, endDate); | ||||
| TotalMinutes(DateTime? startDate, DateTime? endDate) | date representing starting point to count minutes | date representing end point to count minutes | number representing total minutes between startDate and endDate | var startDate = Date("2022-12-20"); var endDate = Date("2022-12-25"); return TotalMinutes(startDate, endDate); | ||||
| TotalHours(DateTime? startDate, DateTime? endDate) | date representing starting point to count hours | date representing end point to count hours | number representing total hours between startDate and endDate | var startDate = Date("2022-12-20"); var endDate = Date("2022-12-25"); return Hours(startDate, endDate); | ||||
| TotalDays(DateTime? startDate, DateTime? endDate) | date representing starting point to count days | date representing end point to count days | number representing total days between startDate and endDate | var startDate = Date("2022-12-20"); var endDate = Date("2022-12-25"); return TotalDays(startDate, endDate); | ||||
| TotalTime(DateTime? startDate, DateTime? endDate, string timeMeasure) | date representing starting point to count time | date representing end point to count time | case insensitive string describing measure of time (milliseconds, seconds, minutes, hours, days) | number representing total time between startDate and endDate measured in unit specified in 3rd parameter, or null if measure is wrong | var startDate = Date("2022-12-20"); var endDate = Date("2022-12-25"); return TotalTime(startDate, endDate, "DAYS"); | |||
| ToString(string value) | string to convert to string | converted string | return ToString("Hello World!"); | |||||
| ToString(object value) | object to convert to string | converted string | var object = ToObject(1); return ToString(object); | |||||
| ToString(decimal? value) | number to convert to string | converted string | return ToString(16); | |||||
| ToString(bool? value) | boolean to convert to string | converted string | return ToString(true); | |||||
| ToString(DateTime? value) | date to convert to string | converted string | var date = Date(2017, 12, 13); return ToString(date); | |||||
| ToString(DateTime? value, string format) | date to convert to string | string representing date format | converted string in specified format | var date = Date(2017, 12, 13); return ToString(date, "MM/dd/yyyy"); | https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings | |||
| Substring(string literal, int? index) | string to take substring from | number representing start position of the substring in first parameter | substring from defined position | return Substring("Hello World", 6); | ||||
| Substring(string literal, int? index, int count?) | string to take substring from | number representing start position of the substring in first parameter | number of characters to take | substringed from defined position and with defined length | return Substring("Hello World", 6, 1); | |||
| Contains(string literal, string value) | string representing source to search | string representing value to search in source | boolean defining whether parameter1 contains parameter2 | return Contains("Hello World!", "World"); | ||||
| Contains(List | list of strings representing source to search | string representing value to search in source | boolean defining whether list contains string | return Contains([EC Project SDGs], "No Poverty"); | Can be used on resources that represent array of strings like [EC Project SDGs] | |||
| StartsWith(string literal, string value) | string to check | string representing check value | boolean defining whetherfirst parameter starts with second parameter | return StartsWith("Hello World!", "Hello"); | ||||
| StartsWith(string literal, string value, bool? ignoreCase) | string to check | string representing check value | boolean indicating if check is case insensitive | boolean defining whetherfirst parameter starts with second parameter | return StartsWith("Hello World!", "hELLo", true); | |||
| EndsWith(string literal, string value) | string to check | string representing check value | boolean defining whetherfirst parameter ends with second parameter | return EndsWith("Hello World!", "World!"); | ||||
| EndsWith(string literal, string value, bool? ignoreCase) | string to check | string representing check value | boolean indicating if check is case insensitive | boolean defining whetherfirst parameter ends with second parameter | return EndsWith("Hello World!", "wORLd!", true); | |||
| Trim(string literal) | string to trim | string trimmed of whitespaces from start and end | return Trim(" Hello World! "); | |||||
| Trim(string literal, string value) | string to trim | string representing trim characters | string trimmed of specified character sequence from start and end | return Trim("abcHello World!abc", "abc"); | ||||
| TrimStart(string literal, string value) | string to trim | string representing trim characters | string trimmed of specified character sequence from start | return Trim("abcHello World!", "abc"); | ||||
| TrimEnd(string literal, string value) | string to trim | string representing trim characters | string trimmed of specified character sequence from end | return Trim("Hello World!abc", "abc"); | ||||
| Replace(string literal, string oldValue, string newValue) | source string | string representing substring to replace in source | string that will replace all occurances of parameter2 in source | string with preplaced all occurances of parameter2 with parameter3 in parameter1 | return Replace("Helloo Woorld!", "oo", "o"); | |||
| Insert(string literal, decimal? index, string value) | string to insert substring to | integer representing position in parameter1 where to inject parameter3 | string to inject at specified position in source string | string with injected substring at specified position | return Insert("H world!", 1, "ello"); | |||
| IndexOf(string literal, string value) | source string | string to search for in source | number representing zero based index of the first occurance of the value substring in source string, -1 if not found | return IndexOf("Hello World!", "H"); | ||||
| IndexOf(string literal, string value, bool? ignoreCase) | source string | string to search for in source | boolean indicating if search is case insensitive | number representing zero based index of the first occurance of the value substring in source string, -1 if not found | return IndexOf("Hello World!", "h"); | |||
| IndexOf(string literal, string value, decimal? index) | source string | string to search for in source | number representing position of search start | number representing zero based index of the first occurance of the value substring in source string starting at specified position, -1 if not found | return IndexOf("Hello World!", "e", 1); | |||
| IndexOf(string literal, string value, decimal? index, bool? ignoreCase) | source string | string to search for in source | number representing position of search start | boolean indicating if search is case insensitive | number representing zero based index of the first occurance of the value substring in source string starting at specified position, -1 if not found | return IndexOf("Hello World!", "E", 1); | ||
| IndexOf(string literal, string value, decimal? index, decimal? count) | source string | string to search for in source | number representing position of search start | number of character positions to check | number representing zero based index of the first occurance of the value substring in source string starting at specified position and checking specified number of characters, -1 if not found | return IndexOf("Hello World!", "e", 1, 1); | ||
| IndexOf(string literal, string value, decimal? index, decimal? count, bool? ignoreCase) | source string | string to search for in source | number representing position of search start | number of character positions to check | boolean indicating if search is case insensitive | number representing zero based index of the first occurance of the value substring in source string starting at specified position and checking specified number of characters, -1 if not found | return IndexOf("Hello World!", "E", 1, 1); | |
| LastIndexOf(string literal, string value) | source string | string to search for in source | number representing zero based index of the last occurance of the value substring in source string, -1 if not found | return LastIndexOf("Hello World!", "l"); | ||||
| LastIndexOf(string literal, string value, bool? ignoreCase) | source string | string to search for in source | boolean indicating if search is case insensitive | number representing zero based index of the last occurance of the value substring in source string, -1 if not found | return LastIndexOf("Hello World!", "L"); | |||
| LastIndexOf(string literal, string value, decimal? index) | source string | string to search for in source | number representing position of search start | number representing zero based index of the last occurance of the value substring in source string starting at specified position and going backwards, -1 if not found | return LastIndexOf("Hello World!", "l", 9); | |||
| LastIndexOf(string literal, string value, decimal? index, bool? ignoreCase) | source string | string to search for in source | number representing position of search start | boolean indicating if search is case insensitive | number representing zero based index of the last occurance of the value substring in source string starting at specified position and going backwards, -1 if not found | return LastIndexOf("Hello World!", "L", 9); | ||
| LastIndexOf(string literal, string value, decimal? index, decimal? count) | source string | string to search for in source | number representing position of search start | number of character positions to check | number representing zero based index of the last occurance of the value substring in source string starting at specified positionand going backwards and checking specified number of characters, -1 if not found | return LastIndexOf("Hello World!", "l", 9, 1); | ||
| LastIndexOf(string literal, string value, decimal? index, decimal? count, bool? ignoreCase) | source string | string to search for in source | number representing position of search start | number of character positions to check | boolean indicating if search is case insensitive | number representing zero based index of the last occurance of the value substring in source string starting at specified positionand going backwards and checking specified number of characters, -1 if not found | return LastIndexOf("Hello World!", "L", 9, 1); | |
| PadLeft(string literal, decimal? totalWidth) | source string | number of spaces | string that right-aligns the characters in this instance by padding them with spaces on the left, for a specified total length | return PadLeft("Hello World!", 1); | ||||
| PadLeft(string literal, decimal? totalWidth, string paddingChar) | source string | number of characters | string defining characters to pad with | string that right-aligns the characters in this instance by padding them with specified sequence of characters on the left, for a specified total length | return PadLeft("Hello World!", 1, "a"); | |||
| PadRight(string literal, decimal? totalWidth) | source string | number of spaces | string that left-aligns the characters in this instance by padding them with spaces on the right, for a specified total length | return PadRight("Hello World!", 1); | ||||
| PadRight(string literal, decimal? totalWidth, string paddingChar) | source string | number of characters | string defining characters to pad with | string that left-aligns the characters in this instance by padding them with specified sequence of characters on the right, for a specified total length | return PadRight("Hello World!", 1, "a"); | |||
| Remove(string literal, decimal? index) | string to remove from | number representing position to start removing from | string where all characters from source string starting from defined position have been removed | return Remove("Hello World!", 5); | ||||
| Remove(string literal, decimal? index, decimal? count) | string to remove from | number representing position to start removing from | number of characters to remove | string where specified number of characters from source string starting from defined position have been removed | return Remove("Hello World!", 5, 6); | |||
| ToLower(string literal) | source string | lowercase string representation of source string | return ToLower("HELLO WORLD!"); | |||||
| ToLowerInvariant(string literal) | source string | lowercase string representation of source string using the casing rules of invariant culture | return ToLower("HELLO WORLD!"); | |||||
| ToUpper(string literal) | source string | uppercase string representation of source string | return ToUpper("hello world!"); | |||||
| ToUpperInvariant(string literal) | source string | uppercase string representation of source string using the casing rules of invariant culture | return ToUpper("hello world!"); | |||||
| Length(string literal) | source string | number representing length of the source string | return Length("Hello World!"); | |||||
| Min(decimal x, decimal y) | first number to compare | second number to compare | smaller of the 2 numbers | return Min(2,3); | ||||
| Max(decimal x, decimal y) | first number to compare | second number to compare | larger of the 2 numbers | return Max(2,3); | ||||
| Pow(decimal x, decimal y) | base number | power number | number x raised to the power of y | return Pow(3,4); | ||||
| Abs(decimal x) | number | returns absolute value of the number | return Abs(-4); | |||||
| Acos(decimal x) | number | number representing angle whose cosine is specified number | return Acos(0.25); | |||||
| Asin(decimal x) | number | number representing angle whose sine is specified number | return Asin(-1); | |||||
| Atan(decimal x) | number | number representing angle whose tangent is specified number | return Atan(0.5); | |||||
| Atan2(decimal x, decimal y) | number representing x coordinate of the point | number representing y coordinate of the point | number that represents angle whose tangent is the quotient of two specified numbers | return Atan2(4,-3); | ||||
| Ceiling(decimal x) | number | Returns the smallest whole value that is greater than or equal to the specified number | return Ceiling(3.7); | |||||
| Cos(decimal x) | number representing angle | number representing cosine of the specified angle | return Cos(3.14); | |||||
| Cosh(decimal x) | number representing angle | number representing hyperbolic cosine of the specified angle | return Cosh(0); | |||||
| Exp(decimal x) | number representing power of e | e raised to the specified power | return Exp(2); | |||||
| Floor(decimal x) | number | largest whole number less than or equal to the specified number | return Floor(3.3); | |||||
| IEEERemainder(decimal x, decimal y) | dividend | divisor | Remainder resulting from the division of a specified number by another number | return IEEERemainder(4,3); | ||||
| Log(decimal x) | number | natural (base e) logarithm of a specified number | return Log(5); | |||||
| Log10(decimal x) | number | base 10 logarithm of a specified number | return Log10(6); | |||||
| Round(decimal x, decimal y) | number to be rounded | number of decimal places in the return value | number nearest to d that contains a number of fractional digits equal to decimals | return Round(2.5432598, 3); | ||||
| Sign(decimal x) | number | number that indicates the sign of value, -1 meaning number is negative, 0 number is 0 and 1 meaning number is positive | return Sign(-45); | |||||
| Sin(decimal x) | number representing angle | number representing sine of the specified angle | return Sin(0); | |||||
| Sinh(decimal x) | number representing angle | number representing hyperbolic sine of the specified angle | return Sinh(0); | |||||
| Sqrt(decimal x) | number | square root of specified number | return Sqrt(2); | |||||
| Tan(decimal x) | number representing angle | number representing tangent of the specified angle | return Tan(0); | |||||
| Tanh(decimal x) | number representing angle | number representing hyperbolic tangent of the specified angle | return Tanh(0); | |||||
| Truncate(decimal x) | decimal number | whole part of a specified decimal number | return Truncate(3.1345); | |||||
| Count(List | list of strings | number of elements in the list | return Count([EC Project SDGs]); | Can be used on resources that represent array of strings like [EC Project SDGs] | ||||
| Count(List | list of objects | number of elements in the list | ||||||
| Count(List | list of numbers | number of elements in the list | ||||||
| Count(List | list of booleans | number of elements in the list | ||||||
| Count(List | list of dates | number of elements in the list | ||||||
| FirstOrDefault(List | list of strings | first string from the list or null if list is empty | return FirstOrDefault([EC Project SDGs]); | Can be used on resources that represent array of strings like [EC Project SDGs] | ||||
| FirstOrDefault(List | list of objects | first string from the list or null if list is empty | ||||||
| FirstOrDefault(List | list of numbers | first object from the list or null if list is empty | ||||||
| FirstOrDefault(List | list of booleans | first number from the list or null if list is empty | ||||||
| FirstOrDefault(List | list of dates | first boolean from the list or null if list is empty | ||||||
| first date from the list or null if list is empty |