DAX Functions Flashcards

1
Q

ALL ( )

What does ALL ( ) return outside of a CALCULATE function?

A

ALL returns a table including all rows, ignoring any filters that might have been applied. Includes blank rows.

(Use ALLNOBLANKROW if you don’t want blanks).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ALL ( )

When used with a column that has duplicate values, what does ALL do with the duplicates?

A

Used with a column that has duplicate values, ALL will collapse them all into a single value before returning the table. For example, ALL( [Product[UnitPrice] ) will return a table that lists the multiple values into one unique value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ALL ( )

What does ALL return when acting as a CALCULATE modifier?

A

As a CALCULATE modifier, ALL removes filters from the table and does not return a table. It becomes a CALCULATE modifier, not a table function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ALLSELECTED ( )

What is the common use of ALLSELECTED as it relates to the current visual?

A

ALLSELECTED will allow you to get the “visual totals.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Filter Intersection

What survives when filters intersect (e.g. within nested CALCULATE statements)?

A

When filters intersect, only the common element will survive.

So for example only black will survive the intersection between these inner and outer CALCULATE filter contexts:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Tables

What is an “anonymous table” and how do you indicate it?

A

Anonymous tables are created “in-line” within code. They can be created within curly brackets:

{ “James”, “David”, “Leah”, “Hannah” }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

IN

What is the IN function used for?
What is it syntax sugar for?

A

IN simplifies logical conditions checking whether a certain value is included in a list of values or expressions.

IN is syntax sugar for the CONTAINSROWS function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

KEEPFILTERS ( )

Within what function does KEEPFILTERS have to be used?

A

KEEPFILTERS can only be used within a CALCULATE function as a filter modifier (not a CALCULATE modifer).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between a CALCULATE modifier and a filter modifier?

A

A filter modifier changes the behaviour of only one filter argument within CALCULATE.

A CALCULATE modifier changes the global behaviour of CALCULATE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

KEEPFILTERS ( )

What does KEEPFILTERS do?
Provide three instances in which you want to use it.

A

KEEPFILTERS combines the new filter applied by CALCULATE with the existing external filter.

Use it when you:

  • Do not want to overwrite existing filters — wrap it in this function.
  • Want to return a blank if your visual is not sliced by the dimension wrapped in the function.
  • You can also use this to intersect between filter context external to the measure and the filter of the CALCULATE statement.
    For example: KEEPFILTERS (Product[Color] IN {“Red”, “White”, “Blue”} Will return a blank if the visual’s slicer elements don’t include one of the three colours.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

IN

What is the syntax of IN with both one column and multiple columns.

A

One column:

Products [Color] IN { “Red”, “Black” }

Two columns have to be in brackets:

( ‘Product’[Color], ‘Product’[Brand] ) IN
{
( “Red”, “Litware” ),
( “Blue”, “Contoso” )
}
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

REMOVEFILTERS ( )

When used within a CALCULATE function, what does this function behave like?

A

When used in a CALCULATE expression, REMOVEFILTERS behaves exactly like ALL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

FILTER ( )

When would you use FILTER within the CALCULATE function?

A

If you’re retrenching two or more different columns in a single CALCULATE filter argument, you have to use FILTER. (Multiple values for a single column can be used as a CALCULATE filter argument predicate without this function).

However, only do it when you know what you’re doing. Expensive in both performance and accuracy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

VALUES ( )

What does VALUES return and what are two examples in which you would use it?

A

VALUES returns the list of values of a column visible in the current filter context.

  • Because it returns a table, VALUES can be used as a filter argument in CALCULATE.
  • Can be used in CALCULATE to restore a specific filter after removing everything with ALL.

EXAMPLE:

CALCULATE (
[Sales Amount],
ALL ( Sales ),
VALUES ( ‘Date’[Calendar Year] )

)

This removes all the filters off the fact table (and off any table filtering the fact table because of relationships and expanded tables) and then reapplies any filter visible in the current filter context

This is a common technique to use VALUES after ALL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Filters

How do I know when to keep or remove filters?

What function will be a frequent choice when calculating percentages?

A

Think about the calculation - for example, do I want a % of a category or of a whole?

  • If you remove the filter from category you’d end up the % being of the whole.
  • If you keep filter on the category the % will be of the category.
  • Returning the filter to Year makes the year % of the year.

KEEPFILTERS may often be your tool of choice.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SUM and SUMX

What is the difference between these two functions?

A

SUM requires a single column. You cannot sum two separate columns together.

SUMX will allow you to evaluate an expression with more than one column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

LASTNONBLANK ( )

What kind of function is LASTNONBLANK and what does it do?

A

LASTNONBLANK is an iterator.

It returns the last date in the date table for which it’s second argument does not produce a blank result.

The first argument is probably your Date column - remember you want it to return a date.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

ISINSCOPE ( )

What does ISINSCOPE do?
When is it commonly used?

A

ISINSCOPE is similar to ISFILTERED but also checks that the column is being used as a Group-By column. Returns TRUE when the specified column is the level in a hierarchy.

Useful to avoid detecting slicers as filters.

Commonly used in DAX to compute percentages that adapt to hierarchy groups in a visual or matrix so that it automatically adapts to what the user selects.

Eg: if a hierarchy is applied to category - subcategory- product then you would want the percentages to show at different levels:

Category as a percentage of the grand total

Subcategories as a percentage of category

Product as a percentage of category

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

SUMMARIZE

What does SUMMARIZE do?

A

SUMMARIZE performs GROUP BY in DAX and optionally calculates subtotals.

Never use this function to computer calculated columns - you may get unexpected results. Instead use a mix of SUMMARIZE and ADDCOLUMNS.

You can include columns of other tables as long as there is a many to one relationship between the two tables, starting from the table you provide in the first argument.

To be in full control, use only for SELECT DISTINCT purposes and then wrap it in ADDCOLUMNS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

SUMMARIZECOLUMNS What does this function do and why would it not be used often in measures?

A

SUMMARIZECOLUMNS is kind of a SUMMARIZE 2.0 and can be used in a query with EVALUATE, but it can hardly be used in a measure because it doesn’t suppport context transition.

It’s more important to be able to read this function but you likely won’t use it much in Power BI.

Note, however, that the function is used by Power BI itself all the time. You’ll see it when you use DAX studio to read the queries produced by the engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

CROSSJOIN

What does this function do?

A

CROSSJOIN creates the cartesian product of two tables.

Won’t be used often in measures, but could be useful to solve certain performance issues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Iterators

When would you use double iteration functions and what does it look like?

A

If you’re iterating over a column in one table but you want to do it based on values in a column in another table, you can introduce double iterations.

SUMX (
‘Product’,
SUMX (
FILTER (
RELATEDTABLE( Sales ),
Sales[Order Date] >= ‘Product’[FirstSaleDate] &&
Sales[Order Date] < ‘Product’[FirstSaleDate] + 7
),
Sales[Quantity] * Sales[Net Price]
)
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the difference between Filters and Row Context?

A

A filter always filters and has no row context. Think of it as building a table of values that meet the conditions.

A row context always iterates. It does something to each line within a table.

“They have nothing to share.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How does Row Context relate to measures vs calculated columns?

A

A measure does not have a row context by default. If you need one, you must introduce one with an iterator.

A calculated column already has a row context by default, so you don’t need to use an iterator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How does Row Context within one table interact with other tables?

A

The row context does not interact in any way with relationships in other tables (unless you are excplicit about it and use RELATED or RELATEDTABLE).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

RELATED ( )

In what type of table relationship would you use RELATED?

A

RELATED: Useful when you have a row context on the Many side of a relationship and you want to follow the relationship to the One side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

RELATEDTABLE ( )

In what type of table relationship would you use RELATEDTABLE?

A

RELATEDTABLE: Useful when you start on the One side to the Many side

This makes sense when you think about it - if there could be more than one value returned from the relationship you’re reaching out to, then it has to be returned as a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Filter Context

What direction does filter context move from in table relationships?

A

Filter context automatically moves from the One side to the Many side of the relationship.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is Context Transition?

When would you not use it?

A

Context transition is an operation performed by CALCULATE and CALCULATETABLE in the definition of the new filter context, under which it evaluates its expression.

CALCULATE invalidates any row context. It automatically adds as filter arguments all the columns that are currently being iterated in any row context — filtering their actual value in the row being iterated.”

As a result it is expensive - one filter for every single column in the table, repeated for every row in the table. You have to use context transition carefully.

** important note: context transition should not be used over tables that might contain duplicates rows. It will inflate the results!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Why should you never call CALCULATE when iterating over a table that does not have all unique rows (doesn’t have a primary key, i.e. a fact table)?

A

Because it will inflate the results.

This includes when you call another measure within a measure based on an iterator (e.g. SUMX). When you do this, DAX automatically wraps the measure inside of a hidden CALCULATE function! Inside an iterator, the hidden CALCULATE function invokes context transition. This works fine if there are unique rows (where it can identify the only row being duplicated). But if not then it collapses all the duplicate values into one!! In such cases, instead of calling the measure within the measure, write out the equation found in the measure being called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Filters

What is the general rule when filtering tables to protect performance?

A

When filtering tables, always choose to do so in the smallest number of columns possible needed for the calculation. This maintains performance. Don’t just filter the entire table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

MAXX ( )

What does this function do?

What does it look like?

How does Context Transition happen?

A

MAXX sums at a row level and aggregates the max.

Example :=
MAXX (
Date,
[Sales Amount]
)

If the filter context is year it still only shows the highest daily max for the year.

In this code the context transition happens from the date table to sales because when you call a measure in an iterator it’s wrapped in a hidden CALCULATE statement and therefore invokes context transition. In this example the row context is daily therefore carries through into the year and month level with the daily max.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Name 5 common iterator functions and 2 less common.

A

Common:

  1. SUMX
  2. MINX
  3. MAXX
  4. AVERAGEX
  5. RANKX

Less common:

  1. PRODUCTX (useful for compound interest)
  2. CONCATENATEX
34
Q

Time Intelligence

Within what function would you usually use time intelligence functions?

A

Most of the time you use Time Intelligence functions as arguments in a CALCULATE function.

35
Q

Time intelligence

Why is it important to ensure all possible dates are found in the date table?

A

If all possible dates are NOT found in the date table, the time intelligence function returns a blank, and you may end up with completely wrong answers without being aware of it.

36
Q

DATESBETWEEN ( )

What does this function do and what is the syntax?

A

DATESBETWEEN returns a table between two dates.

Syntax:

DATESBETWEEN ( ‘Dates’, start_date, end_date)

If you leave the first argument blank it will return all the dates. Could be a technique to use if there is no Time Intelligence function for your purposes.

37
Q

DATESYTD ( )

What does this function do and what is the syntax?

How can it handle a fiscal year?

A

DATESYTD returns a table with all the dates in the current year up to the current date and resets in January.

Syntax: DATESYTD ( ‘Dates’, [year_end_date])

Example:

Sales YTD =
CALCULATE (
[Sales Amount],
DATESYTD ( ‘Date’[Date] )
)

You can use an optional 2nd argument to indicate the last day of the fiscal year:

DATESYTD ( ‘Date’[Date], ”06-30” )

38
Q

TOTALYTD ( )

What does this function do and what is the syntax?

A

TOTALYTD evaluates the year-to-date value of the expression in the current context.

Syntax:

TOTALYTD ( expression, Date[Date], [filter] , [year_end_date] )

39
Q

DATEADD ( )

What does this function do and what is the syntax?

A

DATEADD shifts a table back and forth over time, using parameters to define the shift period. The period can be DAY, MONTH, QUARTER or YEAR.

Syntax:

DATEADD (Dates[Date], number_of_intervals, interval)

Intervals: year, quarter, month, day

40
Q

SAMEPERIODLASTYEAR ( )

What does this function do and what is the syntax?

A

SAMEPERIODLASTYEAR returns a table that contains a column of dates shifted one year back in time from the dates in the specified dates column, in the current context.

Only one argument.

Syntax:

SAMEPERIODLASTYEAR ( ‘Dates’ )

41
Q

PARALLELPERIOD ( )

What does this function do and what is the syntax?

A

PARALLELPERIOD returns a table that contains a column of dates that represents a period parallel to the dates in the specified dates column, in the current context, with the dates shifted a number of intervals either forward in time or back in time.

Don’t confuse this with DATEADD. This one gives the total. For example if you’re comparing sales YTD with the total from the previous year, PARALLELPERIOD will give you the entire PY total.

Syntax:

PARALLELPERIOD ( Dates[Date], number_of_intervals, interval)

Intervals: year, quarter, month.

42
Q

PREVIOUSYEAR / PREVIOUSQUARTER / PREVIOUSMONTH

What do these functions do?

A

Similar to PARALLELPERIOD in that they all return the total for that period.

Review documentation when deciding between these and PARALLELPERIOD as there are slight differences (not discussed in depth in the lecture).

43
Q

DATESINPERIOD ( )

What does this function do and what is the syntax?

What is a common application of the function?

A

DATESINPERIOD returns a table that contains a column of dates that begins with a specified start date and continues for the specified number and type of date intervals.

This function is suited to pass as a filter to the CALCULATE function. Use it to filter an expression by standard date intervals such as days, months, quarters, or years.

Syntax:

DATESINPERIOD ( Dates[Date], start_date, number_of_intervals, interval)

Intervals: DAY, MONTH, QUARTER, and YEAR

Common application is for rolling totals (eg sales in the previous 12 months). Used to even out changes in seasons.

If there’s no data file the period of comparison (eg -12 months), it fills with current YTD.

44
Q

NEXTDAY ( )

What does this function do and what is the syntax?

A

NEXTDAY

This function returns all dates from the next day to the first date in the input parameter. For example, if the first date in the dates argument refers to June 10, 2009; then this function returns all dates equal to June 11, 2009.

Syntax:

NEXTDAY ( Dates[Date] )

Remember this returns a table containing the date, not just the date itself.

45
Q

LASTDATE ( )
What does this function do and what is the syntax?

A

LASTDATE returns the last date in the current context for the specified column of dates.

Syntax: LASTDATE ( Dates[Date] )

Similar to MAX but it returns the date as a table, not just a value. Thus it can be used as a filter argument in CALCULATE.

It returns the last date in the date table. But what it doesn’t do is find the last date for which there is data. Thus if you use it for example to show the balance of an account on the last date of the quarter but there is no data on that day, it will return a blank instead of returning the last balance available.

Remember that what it returns is based on the filter context. If the calculation is sliced by quarter, it’s the last date of the quarter. If sliced by month, it’s the last date of the month. You may not have data in the fact table on those dates and thus you end up with blanks.

46
Q

Time Intelligence

What do you do if there is no existing native Time Intelligence function for what you need to do?

A

Time Intelligence functions just return a table of dates, so you can write them out longhand if the native functions don’t exist. (Eg running total since the beginning of data).

47
Q

What is an additive measure?

A

An additive measure uses SUM to aggregate over any attribute.

The sales amount is a perfect example of an additive measure. Indeed, the sales amount for all customers is the sum of the individual sales for each customer; at the same time, the amount over a year is the sum of the amounts for each month.

48
Q

What is a non-additive measure?

A

A non-additive measure does not use SUM over any dimension.

Distinct count is the simplest example: the distinct count of products sold over a month is not the sum of the distinct counts of individual days.

The same happens with any other dimension: a distinct count of products sold in a country is not the sum of the distinct counts of the products sold in each city in the country.

49
Q

What is a semi-additive measure and what is an example of one?

A

A semi-additive measure uses SUM to aggregate over some dimensions and a different aggregation over other dimensions – a typical example being time.

Classic example is the balance of a current account.

50
Q

What is auto date/time and how do you disable it?

A

The Auto date/time is a data load option in Power BI Desktop. The purpose of this option is to support convenient time intelligence reporting based on date columns loaded into a model.

Disable this under options for a new file.

It creates a full date table for each of the columns in your data that has a date.

51
Q

DISTINCT ( )
What does this function do?

A

DISTINCT returns the distinct values of a table, not considering blank values. VALUES should be the default choice instead because it includes the blank rows.

52
Q

ADDCOLUMNS

What kind of function is this?
What does this function do?
With what two functions is it frequently used?

A

ADDCOLUMNS is an iterator.

It returns a table that merges a source table with one or more expressions evaluated in the row context to create a new table.

ADDCOLUMNS is frequently used with FILTER to obtain filters on temporary calculated columns.
Also frequently used with SUMMARIZE because temporary columns created by that function creates one row context and one filter context at the same time and is overly complex to understand.

53
Q

QUERIES

What are queries and why are we learning them?

Name four keywords often used in them.

A

Queries are constructed by reporting clients (eg Power BI) whenever a field is placed on a report surface, or a filter or calculation is applied.

At the most basic level, a DAX query is an EVALUATE statement containing a table expression.

Query functions are useful in creating calculated columns but less useful in measures.

Keywords are
EVALUATE
ORDER BY
START AT
DEFINE

54
Q

EVALUATE
Where is this function used and what does it do?
What is the syntax?

A

EVALUATE is needed to execute a query. It returns the result of a table expression.

Syntax has 3 sections:

  1. Optional definition section (DEFINE).
  2. Required query expression(s) (EVALUATE).
  3. Optional result modifiers (ORDER BY/START AT).
55
Q

DEFINE
Where is this function used and what does it do?

A

DEFINE is used within queries.

This function defines local entities like tables, columns, variables, and measures. There can be a single DEFINE for the whole query although it may contain multiple EVALUATE statements.

56
Q

GENERATE
What does this function do?

What is the syntax?

A

GENERATE iterates every row in the table of the first argument, evaluates the expression in a row context of the iteration and then combines the two together.

The second table expression will be evaluated for each row in the first table. Returns the crossjoin of the first table with these results.

Syntax:

GENERATE ( Table1, Table2)

57
Q

TOPN

What does this function do?

What is the default order?

How does it handle ties?

A

TOPN creates a filter of rows according to a specified expression.

Descending order is default but you can change to ascending in the syntax.

In the case of ties, all rows are displayed. You may end up with more than N rows listed as a result.

58
Q

QUERIES

Name two table functions commonly found in queries that could sometimes be used in measures, and explain two reasons why they could be used so.

A

Two common functions found in queries are:
GENERATE
TOPN

Reasons why they could be used in measures:

  1. To create calculated tables to extend the data model.
  2. To create complex reports
59
Q

ROW

What does this function do?

Why is it necessary?

A

ROW creates a one row table while controlling the name of the column.

Necessary because EVALUATE requires a table function and can’t just create a table from a measure. ROW allows you to creat such a table. Using two arguments: column name assignment and an expression.

60
Q

Calculated columns

When deciding between creating calculated columns or measures, name three reasons when calculated columns are necessary.

A

Calculated columns are required whenever you want to:

  1. Place the calculated results in a slicer or see results in rows/columns of a matrix (as opposed to the Values area), or use the calculated column as a filter condition in a DAX query.
  2. Define an expression that is strictly bound to the current row (e.g. Price * Quantity)
  3. Categorize text or numbers (e.g. a range of ages) to use as filters or to slice values.
61
Q

Error Interceptors

Name three functions commonly used in intercepting errors.

A

IFERROR

IF - ISERROR

ISBLANK

62
Q

IFERROR

What does this function do?
When would you use it over ISERROR?
What is the syntax?

A

IFERROR is similar to the IF function, but instead of evaluating a Boolean condition, it checks whether an expression returns an error. It will either return a specified value or the result of the expression (if no error).

Use IFERROR when the expression is the desired output.

Syntax: IFERROR ( value, value_if_error )

63
Q

ISERROR

What does this function do?
When would you use it over IFERROR?
What is the syntax?

A

ISERROR checks whether a value is an error, and returns TRUE or FALSE. Commonly used with IF / ISERROR.

Use IF/ISERROR when you want to return the result of a difference expression.

Syntax: ISERROR (value)

64
Q

Error Handling

Why must you be careful when using error interceptors?
What is a better way of handling possible errors>

A

Error handling functoins might create severe performance issues. The DAX engine cannot use optimzed paths in its code when errors happen.

In most cases, checking operands for possible errors is more efficient than using the error-handling engine (“IF”)

65
Q

SWITCH

What does this function do?
What does it replace?
What is the syntax?

A

SWITCH evaluates an expression against a list of values and returns one of multiple possible result expressions.

Use it instead of nested IF statements.

Syntax:

SWITCH (
Expression,
Value, Result,
Value, Result…..,
Else
)

66
Q

Information Functions

Name six IS____ functions.

What type of value do they return?

A

ISBLANK

ISERROR

ISLOGICAL

ISNONTEXT

ISNUMBER

ISTEXT

They all return Boolean values T/F.

67
Q

Mathematical Functions

FLOOR

What does this function do?
What is the syntax?
What would it return for 1.123450?

A

FLOOR rounds a number down, toward zero, to the nearest multiple of significance (indicated by the second argument).

Syntax: FLOOR ( Number, Significance)

Significance is indicated by a number “0.01” rounds down to nearest hundredth. Both arguments must be positive or both be negative.

FLOOR (1.123450, 0.01 ) would return: 1.12

68
Q

Mathematical Functions

TRUNC

What does this function do?
What is the syntax?
What would 1.123450 return?

A

TRUNC truncates a number to an integer by removing the decimal.

Syntax: TRUNC ( Number, Number of Digits). If the 2nd argument is left blank, defaults to zero.

TRUNC (1.12345, 2 ) Returns: 1.12

69
Q

Mathematical Functions

ROUNDDOWN

What does this function do?
What is the syntax?
What would 1.123450 return?

A

ROUNDDOWN rounds a number down, toward zero.

Syntax: ROUNDDOWN ( number, num_digits )

ROUNDDOWN (1.123450, 2) returns: 1.12

70
Q

Mathematical Functions

MROUND

What does this function do?
What is the syntax?
What would 1.265001 return?

A

MROUND returns a number rounded to the desired multiple.

Syntax: MROUND (number, multiple )

MROUND ( 1.265001, 0.01 ) returns: 1.27

71
Q

Mathematical Functions

ROUND

What does this function do?
What is the syntax?
What would 1.265001 return?

A

ROUND rounds a number to the specified number of digits.

Syntax: ROUND ( number, num_digits )

ROUND (1.265001, 2) returns: 1.27

Note: to force the direction of rounding use ROUNDUP, ROUNDDOWN.

72
Q

Mathematical Functions

CEILING

What does this function do?
What is the syntax?
What would 1.265001 return?

A

CEILING rounds a number up, to the nearest integer or to the nearest multiple of significance.

Syntax: CEILING (number, significance)

CEILING (1.265001, 0.01) returns: 1.27.

73
Q

Mathematical Functions

ROUNDUP

What does this function do?
What is the syntax?
What would 1.123450 return

A

ROUNDUP rounds a number up, away from 0 (zero).

Syntax: ROUNDUP (number, num_digits )

ROUNDUP (1.123450, 2) returns: 1.13.

74
Q

Mathematical Functions

INT

What does this function do?
What is the syntax?
What would 1.123450 return

A

INT rounds a number down to the nearest integer.

Syntax: INT ( number )

INT (1.123450) returns 1.

75
Q

Mathematical Functions

FIXED

What does this function do?
What is the syntax?
What would 1.123450 return

A

FIXED rounds a number to the specified number of decimals and returns the result as text. You can specify that the result be returned with or without commas.

Syntax: FIXED ( number, decimals, no_commas )

Decimals = # of digits to the right of decimal point (2 default).

No commas = 1 or TRUE (no commas), 0 or FALSE or omitted (show commas)

FIXED (1.123450, 2, TRUE) returns 1.12.

76
Q

Mathematical Functions

How are these functions different from each other?

FLOOR
TRUNC
ROUNDDOWN

A

FLOOR, TRUNC, and ROUNDDOWN differ in the way we can specify the number of digits to round.

77
Q

Conversion functions

Name five conversion functions and what they do.

A
  1. CURRENCY - transforms expresison into currency type.
  2. INT - transforms expression into an Integer
  3. DATE - returns DateTime values
  4. TIME - returns DateTime values
  5. VALUE - transforms a string into a numeric format
  6. FORMAT - transforms numerica values into strings, and is commonly used with DateTime types.
78
Q

Conversion Functions

FORMAT

What does this function do?
What is the syntax?

A

FORMAT converts a value to text according to the specified format.

Syntax: FORMAT (value, “format_string” )

Format strings include:

“yyyy mmm dd”
“d” - Day as number without leading 0 (1-31)
“dd” - Day as number with leading 0 (01-31)
“ddd” - Abbreviated day (Mon, Tue)
“dddd” - full day (Monday)
month works the same as above
“y” - day of the year as # (1-366)
“yy” - year as 2 digits
“yyyy” - full year
“General Number” (no thousands separator)
“Currency”
“Fixed” (at least 1 digit to left, 2 digits to right of decimal)
“Standard” (thousands separator, 1 left/2 right)
“Percent” (2 digits right of decimal)
“Scientific” (1.23E+04)
“Yes/No” (Displays No if number 0, otherwise Yes)
“True/False” (Displays False if number 0, otherwise True)
“On/Off” (Displays Off if number 0, otherwise On)

79
Q

What is the difference between

ADDCOLUMNS and

SELECTCOLUMNS?

A

ADDCOLUMNS allows you to add new calculated columns in an existing table.

SELECTCOLUMNS allows you to select columns from an original table, without starting with the defined structure of the original table.

80
Q
A