Introduction Logical functions in power bi

Logical functions allow us to introduce decision making, these functions are used to check whether the condition is true or false and are also used to combine multiple conditions together.

Logical function is one the most useful expression of DAX in Power BI. So, here in this article you will learn about ‘Logical’ functions and how to use them.

I am going to explain some inportant types of logical functions, so let’s start.

IF

Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE.

Syntax- IF(LogicalTest, ResultIfTrue, [ResultIfFalse])

LogicalTest- Any expression that can be evaluated to TRUE or FALSE

ResultIfTrue – It will be returned if logical test is TRUE.

ResultIfFalse-If logical test is FALSE then it will be returned.

Ex: I have use This condition

Input:

Measure = IF(8>4,”8 is greater than 4″,”8 less than 4″)

Out put:

power bi

AND

Check whether all arguments are TRUE, and returns TRUE if all arguments are TRUE.

Syntax- AND(logical1, Logical2)

Logical1- The Logical value that you want to check.

Logical2- This is also a logical value that you want to check.

Ex. I have use This below conditions

Input:

measure = IF(and(8>4,8<10),”Above statements are true”,”Either first or second statement may be false”)

output:

power bi

 

 

 

 

 

 

Input:

measure = IF(and(8>4,8<4),”Above statements are true”,”Either first or second statement may be false”)

output:

power bi

OR

Returns TRUE if any of the argumenta are TRUE, and returns false if all arguments are FALSE.

Syntax- OR (Logical1, Logical2)

Logical1 – The logic value that you want to check.

Logical2 – The logic value that you want to check.

Ex : I have use This condition

Input :

measure = IF(or(8>7,8<10),”8 will be less than 9″,”8 greater than 9″)

Output :

power bi

TRUE

Return the logical value TRUE always.

Syntax-TRUE()

Ex:

Input :

measure = IF(20<30,TRUE(),FALSE())

Output:

True statement

power bi

 

 

 

 

 

 

False

power bi

COALESCE

Returns the first argument that does not evaluate to BLANK. If all arguments evaluate to BLANK, BLANK is returned.

Syntax- COALESCE(Value1, Value2[,Value3……])

Value1- Any expression that returns the scalar value.

Ex : 

Input:

measure = COALESCE(BLANK(),10,DATE(2003,10,3))
 

Output:

power bi

IFERROR

Returns value_if_error if the first expression is an error and the value of the expression itself otherwise.

Syntax- IFERROR(Value, ValueIfError)

Value- Any expression or value

ValueIfError- Any expression or value

Ex:

Input:

measure = IFERROR(20/0,15)

Output:

power bi

 

 

 

 

 

 

 

In the below example the first value will give an error so, this function will return the second value.

For any Help or Queries Contact us on info@crmonce.com or +91 – 9014146800.

https://www.crmonce.com/add-index-column-in-power-bi-using-power-query-editor/

We have started a new online retail store    Please Visit.