Logical Functions Flashcards

1
Q

IN

A

Returns TRUE if any value in matches any value in .

The values in can be a Set, list of literal values, or a combined field.

Examples:

SUM([Cost]) IN (1000, 15, 200)

[SET] IN [COMBINED FIELD]

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

AND

A

Performs a logical conjunction on two expressions.

Example:

IF (ATTR([Market]) = “Africa” AND SUM([Sales]) > [Emerging Threshold] )THEN “Well Performing”

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

CASE

A

Performs logical tests and returns appropriate values. The CASE function evaluates expression, compares it to a sequence of values, value1, value2, etc., and returns a result. When a value that matches expression is encountered, CASE returns the corresponding return value. If no match is found, the default return expression is used. If there is no default return and no values match, then Null is returned.

CASE is often easier to use than IIF or IF THEN ELSE.

Typically, you use an IF function to perform a sequence of arbitrary tests, and you use a CASE function to search for a match to an expression. But a CASE function can always be rewritten as an IF function , although the CASE function will generally be more concise.

Many times you can use a group to get the same results as a complicated case function.

Examples:

CASE [Region] WHEN ‘West’ THEN 1 WHEN ‘East’ THEN 2 ELSE 3 END

CASE LEFT(DATENAME(‘weekday’,[Order Date]),3) WHEN ‘Sun’ THEN 0 WHEN ‘Mon’ THEN 1 WHEN ‘Tue’ THEN 2 WHEN ‘Wed’ THEN 3 WHEN ‘Thu’ THEN 4 WHEN ‘Fri’ THEN 5 WHEN ‘Sat’ THEN 6 END

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

ELSE

A

Tests a series of expressions returning the value for the first true .

Example:

If [Profit] > 0 THEN ‘Profitable’ ELSE ‘Loss’ END

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

ELSEIF

A

Tests a series of expressions returning the value for the first true .

Example:

IF [Profit] > 0 THEN ‘Profitable’ ELSEIF [Profit] = 0 THEN ‘Breakeven’ ELSE ‘Loss’ END

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

END

A

Tests a series of expressions returning the value for the first true . Must be placed at the end of an expression.

Example:

IF [Profit] > 0 THEN ‘Profitable’ ELSEIF [Profit] = 0 THEN ‘Breakeven’ ELSE ‘Loss’ END

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

IF

A

Tests a series of expressions returning the value for the first true .

Example:

IF [Profit] > 0 THEN ‘Profitable’ ELSEIF [Profit] = 0 THEN ‘Breakeven’ ELSE ‘Loss’ END

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

IFNULL

A

Returns if it is not null, otherwise returns .

Example:

IFNULL([Profit], 0)

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

IIF

A

Checks whether a condition is met, and returns one value if TRUE, another value if FALSE, and an optional third value or NULL if unknown.

Example:

IIF([Profit] > 0, ‘Profit’, ‘Loss’)

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

ISDATE

A

Returns true if a given string is a valid date.

Example:

ISDATE(“2004-04-15”) = True

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

ISNULL

A

Returns true if the expression is NULL (does not contain valid data).

Example:

ISNULL([Profit])

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

MAX

A

Returns the maximum of a single expression across all records or the maximum of two expressions for each record.

Example:

MAX([Sales])

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

MIN

A

Returns the minimum of an expression across all records or the minimum of two expressions for each record.

Example:

MIN([Profit])

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

NOT

A

Performs logical negation on an expression.

Example:

IF NOT [Profit] > 0 THEN “Unprofitable” END

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

OR

A

Performs a logical disjunction on two expressions.

Example:

IF [Profit] < 0 OR [Profit] = 0 THEN “Needs Improvement” END

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

THEN

A

Tests a series of expressions returning the value for the first true .

Example:

IF [Profit] > 0 THEN ‘Profitable’ ELSEIF [Profit] = 0 THEN ‘Break even’ ELSE ‘unprofitable’ END

17
Q

WHEN

A

Finds the first that matches and returns the corresponding .

Example:

CASE [RomanNumberal] WHEN ‘I’ THEN 1 WHEN ‘II’ THEN 2 ELSE 3 END

18
Q

ZN

A

Returns if it is not null, otherwise returns zero.

Example:

ZN([Profit])