BQL Birst Query Language

BQL Birst Query Language

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

DatePart

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

6

All-time users

6

Favorites

0

Last updated

4 years ago

Date created

Mar 1, 2020

Cards (79)

Section 1

(50 cards)

DatePart

Front

Returns integers from dates. DatePart(Year/Month/Day/Hour/Minute/Second, [date attribute]) DatePart(Day,[Time.Date])

Back

NumRows

Front

Returns the total number of rows in the current result set. This function is not available in ETL Services. NumRows() NumRows()

Back

Median

Front

Returns the value in the middle of all measure values at the report grain. An optional break by attribute denoted with "By" can be used. Median([logical column] By [logical attribute column]) Median([OrderDate: Sum: Quantity] By [Product.Product Line])

Back

ATan2

Front

Returns the arc tangent of x and y. ATan2(x,y)

Back

DateDiff

Front

Returns the difference in dates as an integer value. (NULLS are interpreted as 0. ) DateDiff(Year/Month/Day/Hour/Minute/Second, [start date],[end date]) DateDiff(Month,[Order_Details.OrderDate], [Order_Details.RequiredDate])

Back

LookupValue

Front

Lookup based on value in the current result set to get a dimension or measure value from another resultset. Looks for EXACT MATCH. LookupValue (column number from the query, [value in the current query to look at], column number of the new query, Select [new query] from [All]) lookupvalue(0,[Products.CategoryName],1, Select [Products.CategoryName],[OrderDate: Sum: Quantity] from [All])

Back

Add

Front

Allows you to add a value to end of an existing list. Add([ListVariable],10)

Back

Log(x)

Front

Log base e of X. Returns the logarithm of a given number in a specified base. Log([logical column]) Log([OrderDate: Sum: Quantity])

Back

IIF

Front

Immediate IF. Allows an expression to return one result if the specified condition is true and a different one if it is false. Can be nested. IIF(evaluation,result if TRUE, result if FALSE) IIF([OrderDate: Sum: Quantity] >6000, 0, [OrderDate: Sum: Quantity])

Back

GetDayID

Front

This function allows you to return a unique integer signifying the day based on a date or datetime value. [ID Value] = GetDayID([DateValue])

Back

NowDate

Front

Returns current date. You can specify the format to use in the column properties. NOWDATE 2014-03-26

Back

Ln(x)

Front

Returns the natural logarithm of a given number in a specified base. Ln([logical column]) Ln([OrderDate: Sum: Quantity])

Back

IFNULL

Front

Allows an expression to return a different result if it is null. IFNULL(evaluation,result if NULL) IFNULL([OrderDate: Sum: Quantity],0)

Back

Floor(x)

Front

Returns the closest integer less than or equal to a given number. Floor([logical column]) Floor([OrderDate: Sum: Quantity])

Back

AddParentChild

Front

Adds a single parent-child pair to the current list of pairs. AddParentChild([ParentID],[ChildID])

Back

Length

Front

Returns the number of characters in a string. This can also be used in a Birst ETL script to return the number of elements in a List object. Length([dimension]) Length([Products.CategoryName]) ETL Script Example: Length([myList]) - 1

Back

GetMonthID

Front

This function allows you to return a unique integer signifying the month based on a date or datetime value. [ID Value] = GetMonthID([DateValue])

Back

DateAdd

Front

Add or subtract an integer from a date. DateAdd(Year/Month/Day, integer, [Date Attribute]) DateAdd(Day, 5,[Time.Date])

Back

ArcCos

Front

Returns the arc cosine of a number between ο and π. ArcCos([logical column]) ArcCos([OrderDate: Sum: Quantity])

Back

GetLevelValue

Front

For the current pair, GetLevelValue(n) returns the ID n levels deep into the hierarchy. If there are fewer than n levels, it returns the ID of the lowest level available. Hence, the IDs will repeat for levels lower than their depth.

Back

Let

Front

Allows re-use of logic in complex expressions by declaring expression-level variables, initializing them and re-using them in the expression. Let(variable declarations,expression body) Let(Dim [AvgPrice] As Float = LookupValue(0, [Categories.CategoryName],1,Select [Categories.CategoryName],[OrderDate: Avg: UnitPrice] from [All]) Dim [TotalQuantity] As Float = LookupValue(0,[Categories.CategoryName],1,Select [Categories.CategoryName],[OrderDate: Sum: Quantity] from [All]), IIF([AvgPrice]<25,25,[AvgPrice])*[TotalQuantity])

Back

Log10(x)

Front

Log base 10 of x. Log10([logical column]) Log10([OrderDate: Sum: Quantity])

Back

GetWeekID

Front

This function allows you to return a unique integer signifying the week based on a date or datetime value. [ID Value] = GetWeekID([DateValue])

Back

Degrees

Front

Converts x radians to degrees. Degrees(x)

Back

DRank

Front

Dense Rank returns the rank of each row within the result set, without any gaps in the ranking. DRank([measure]) DRank([OrderDate: Sum: Quantity])

Back

Alt:

Front

To use new query language syntax in spaces using classic query language. alt:{expression} alt:Median([OrderDate: Sum: Quantity] by [Time.Year])

Back

Ceiling(x)

Front

Round up. Returns the closest integer greater than or equal to the given number. ceiling([measure]) ceiling([OrderDate: Sum: Quantity])

Back

Now

Front

Returns current date and time. You can specify the format to use in the column properties. NOW 2014-03-26 14:29:19

Back

GetPromptFilter()

Front

A place holder for a dashboard prompt. See Passing Prompt Filters and Values to Expressions and Custom Formulas. GetPromptFilter({prompt name}) [OrderDate: Sum: Quantity] WHERE GetPromptFilter('MyPrompt')

Back

GetVariable()

Front

Retrieves the value of a variable. GetVariable({variable name}) GetVariable('LoadDate')

Back

NextChild

Front

Once a set of parent-child pairs have been added, the list can then be iterated over one by one to flatten. NextChild positions the current record to the next available pair. If there are no more pairs left, it returns false.

Back

Find

Front

Similar to LookupValue, except the lookup value does not need an exact match. If the match is exact that row is returned, otherwise, the first row that is greater than the lookup value is used. Parameters can be added before the logical query and referenced in the logical query using the %index syntax, starting with %0. Find({index of column to lookup},{value to lookup},{index of column to return}, [query]) Find(0,[Products.ProductName],1,Select [Products.ProductName], [OrderDate: Sum: Quantity] From [All])

Back

LookupRow

Front

Use over LoopupValue if the result set will be in the same order as the existing set. LookupRow (index of the row to return, index of the column to return, SELECT [Query] from [ALL]) LookupRow (0,1, Select [OrderDetail.OrderID], [OrderDate: Sum: Discount] from [ALL])

Back

FunctionLookup

Front

Custom functions execute a script over an entire result set to return a result. It works by declaring a return data type (the type of the function) and providing both a script and a logical query. The script is executed for each row of the result set. Additionally, a lookup parameter can be added and will run the function only on rows that satisfy the filter for the targeted column being equal to the value set. The variable [Result] is populated with the return value. FunctionLookup(return data type,lookup parameter,script statement block,logical query)

Back

ArcTan

Front

Returns the arc tangent of a number between -π/2 and π/2. ArcTan([logical column]) ArcTan([OrderDate: Sum: Quantity])

Back

Format

Front

Formats a number or date to the particular format provided. Format([measure]/[date]/[string]) Format([OrderDate: Sum: Quantity],'##,###,##0.00')

Back

Function()

Front

Allows for creation of a custom function that can be used in any logical query including an expression. Function({datatype of return value}, {calculation/script} COMPLETE [Result] = {calculation from script} END COMPLETE) Function (Float, Dim [Var1] as Float = 0.0 Dim [Var2] as Float = 0.0 Complete [Result] = [Var1] - [Var2] End Complete)

Back

Order By

Front

Sort function. Select [query] from [All] Order By [dimension]/[measure] Ascending/Asc/Descending/Desc Select [Product.Category Name], [Time.Year],[Unit Sales] from [All] Order By [Product.Category Name] Ascending, [Time.Year] Descending

Back

Display Where

Front

A display filter. Does the filtering on the returned dataset (the data in cache). Can be used on both dimension columns and measures. Returns entire query but only displays data matching criteria. Select [query] from [All] Display Where [measure]/[dimension]=value Select[Sales] from [All] Display Where [Sales]>10000

Back

Cos

Front

Returns the cosine of a given angle. Cos([logical column]) Cos([OrderDate: Sum: Quantity])

Back

GetPromptValue()

Front

A place holder for a user defined value taken from a dashboard prompt. An optional second argument (such as null or a string such as '2012') can be used in the event that the first argument is not a currently defined prompt. The second argument can also be supplied by a variable using GetVariable(). Note that all values are returned as strings (except null) and must be cast to numeric data types if they are to be used in arithmetic functions. See Passing Prompt Filters and Values to Expressions and Custom Formulas. GetPromptValue({prompt name},{default}) [OrderDate: Sum: Quantity]* Float(GetPromptValue('MyPrompt','2012'))

Back

CAST

Front

Convert data types. Expressions and variables can be cast to different data types. All data types implicitly cast to a varchar so no CAST statement is needed. In the case where the type is not cast-able (e.g., casting 'A' to a float) a NULL is returned. Float() Integer() Date() DateTime() Integer(GetPromptValue('Stage 4 Probability'))

Back

Dtop, Display Top

Front

Displays top N results of the returned dataset. To get the top N from the database, see Top N. Select Dtop x [query] from [all] Order By [dimension]/[measure] Ascending/Asc/Descending/Desc To display the top 5 results of a newly-created expression: SELECT DTOP 5 USING OUTER JOIN [Time.Year] 'F9', [Order_Details.ContactName] 'F11',[OrderDate: Sum: Quantity] 'OrderDate: Sum: Quantity',[OrderDate: Sum: UnitPrice] 'OrderDate: Sum: UnitPrice', [OrderDate: Sum: Quantity]* [OrderDate: Sum: UnitPrice] 'F19' FROM [ALL] ORDER BY [EXPR.F19] ASCENDING NULLS LAST

Back

GetLevelAttribute

Front

Provides additional data either on the entire tree or on a given record that is being processed. Two options are supported. Option 1: GetLevelAttribute('NumLevels') // Returns the maximum depth of items in the tree. Option 2: GetLevelAttribute('CurrentDepth') // Returns the depth of the current item in the tree.

Back

Exp

Front

Returns e raised to the power of the number given. Exp([logical column]) Exp([OrderDate: Sum: Quantity])

Back

Abs(x)

Front

Absolute value of a measure value. abs([measure]) abs([OrderDate: Sum: Quantity])

Back

LTrim

Front

Trims white space from x on the left. LTrim(x)

Back

ArcSin

Front

Returns the arc sine of a number between -π/2 and π/2. ArcSin([logical column]) ArcSin([OrderDate: Sum: Quantity])

Back

IsNaN

Front

Evaluates an expression and returns true if it is not a number and false if it is. The result can be used as a conditional check. IsNaN(evaluation) IIF(IsNaN(evaluation), result if TRUE, result if FALSE) IIF(IsNaN([OrderDate: Sum: Quantity]),0, [OrderDate: Sum: Quantity])

Back

IsInf

Front

Evaluates an expression and returns true if the value is +/- infinity. The result can be used as a conditional check. IsInf(evaluation,result if TRUE, result if FALSE) IIF(IsInf([OrderDate: Sum: Quantity]),0, [OrderDate: Sum: Quantity])

Back

Section 2

(29 cards)

Pi

Front

Pi Pi()

Back

Sin

Front

Returns the sine of a given angle. Sin([logical column]) Sin([OrderDate: Sum: Quantity])

Back

RTrim

Front

Trims all white space from x on the right. RTrim(x)

Back

PTile

Front

Returns the percentile rank of each row within the result set. PTile([measure]) PTile([OrderDate: Sum: Quantity])

Back

Substring

Front

Returns a portion of a given string and assumes a zero based index. Substring([dimension], starting position number, ending position number) Note: First position is 0, ending position is the position after the last one that should be included. Substring([Products.ProductName], 2, 8) The example above returns "member" for "Camembert Pierrot".

Back

Sparse

Front

Allows you to show dimension column values for which there is no fact data. Works with multiple dimensions. See About the Sparse Function for more information. Sparse([dimension]) Sparse([Time.Year])

Back

Pow

Front

Raise x to the power of y. Pow(x,y) Pow(4,2)

Back

Space

Front

Returns x spaces. Space(x)

Back

RowNumber

Front

Returns the row number for the current result set. This function is not available in ETL Services. [RownumVar]=RowNumber() RowNumber()

Back

Sqrt(x)

Front

Returns the square root of a given positive number. sqrt([measure]) sqrt([OrderDate: Sum: Discount])

Back

ToLower

Front

Returns a character expression after converting data to lower case. ToLower([dimension]) ToLower([Products.CategoryName])

Back

Position

Front

Returns the position of a second string within the first. You can specify the starting index to begin the search as an optional third parameter. Position('search string', [dimension], starting position number to begin search) Position('the', [Varchar], 10) (In this example, it would start looking at position 10.)

Back

Rank

Front

Returns the rank of each row within the result set. Rank([logical column]) To rank within a group: Rank([logical column]) BY ([logical column]) Rank([OrderDate: Sum: Quantity]) RANK([OrderDate: Sum: Quantity] BY [Products.CategoryName]) Select [Time.Year],[Product.Category Name], Rank([Unit Sales] BY [Time.Year]) 'Sales Rank' from [All] where [Time.Year]=2011 Or [Time.Year]=2012 Display by [Time.Year] Ascending, [Sales Rank] Ascending

Back

Transform

Front

Directly manipulate or create from scratch the report-level result set. Only one Transform is allowed per logical query. The Transform functions just like an ETL services script. It operates row-by-row over the original result set from the query, using WRITERECORD to output new rows as results. The entire result set is re-written as a result of the TRANSFORM statement. All the input and output columns need to be identical. Transform({script}) Transform(Dim [Odd] As Integer = 0 If (Integer([Odd]/2)*2 = [Odd]) Then [Sum: Quantity]=[Sum: Quantity] WriteRecord End If [Odd] = [Odd] + 1)

Back

ToUpper

Front

Returns a character expression after converting data to upper case. ToUpper([dimension]) ToUpper([Products.CategoryName])

Back

ReplaceAll

Front

Allows a regular expression as the search criteria to replace a value. ReplaceAll(original string/[dimension],[expression],replacement string) ReplaceAll([Products.CategoryName],'P.*e','Organic Produce')

Back

Tan

Front

Returns the tangent of a given angle. Tan([logical column]) Tan([OrderDate: Sum: Quantity])

Back

Sign

Front

Returns +1 for x > 0, 0 for x == 0, and -1 for x <0 Sign(x)

Back

RemoveAt

Front

Allows you to remove an item from a given position in a list. RemoveAt([ListVariable],[IndexToRemove])

Back

Top N

Front

Filter by Top N results from the database. To filter by Top N results in cache, see Display Top. Select Top x [query] from [all] Order By [dimension]/[measure] Ascending/Asc/Descending/Desc SELECT Top 10 USING OUTER JOIN [Order_Date: Sum: Unit Cost] 'Column1' , [Products.Product] 'Column2' FROM [ALL] ORDER BY [Order_Date: Sum: Unit Cost] ASC

Back

Replace

Front

Allows a static string value as the search criteria to replace a value. Replace(original string/[dimension],part to replace,replacement string) Replace([Products.CategoryName], 'ages', 'age')

Back

Rexp

Front

Allows an R expression to be executed inline within a BQL query. Rexp({expected return type}, {R expression to run}). Birst casts the results to the expected return type. Rexp(Number,'predict(model, newdata= data.frame(dist=c('+[Avg: dist]+')))')

Back

Radians

Front

Converts x degrees to radians. Radians(x)

Back

Trend

Front

Uses the Least Squares method to extrapolate values based on a linear trend. Trend({index of column to return},{index of column to lookup},{value to lookup},{logical query}) TREND(1,0,[Time.Month Seq Number], SELECT [Time.Month Seq Number], [OrderDate: Sum: Quantity] FROM [ALL] WHERE [Time.Month Seq Number] >= 1136 AND [Time.Month Seq Number] <= 1148)

Back

Trim

Front

Trims leading and trailing spaces. Can be used in a constant to pad a value. Trim([dimension]) [constant name]= Trim(string value with spaces) Trim([Products.CategoryName]) [BevConstant] = Trim('Beverages')

Back

Random()

Front

Returns a double from 0.0 to 1.0. This function ignores parameter values. Random() Random()

Back

Stat

Front

Aggregate stats based on another result set. Valid aggregations are median, avg, min, max, sum, count, countdistinct, and stddev. Stat(aggregation, index, [query]) Stat(Median, 1,Select [Products.CategoryName], [OrderDate: Sum: Quantity] from [All])

Back

RemoveAll

Front

Removes all elements from a list.

Back

Rsum

Front

Returns the trailing sum of values, based on the window size, at the current report grain for the window provided. Rsum(window size,[logical column]) Rsum(10,[OrderDate: Sum: Quantity])

Back