Logical DAX Function in Power BI

  • Logical functions act upon an expression to return information about the values or sets in the expression.

Logical DAX Function:

  • IFERROR
  • TRUE
  • FALSE
  • SWITCH
  • AND
  • OR
  • NOT
EMPLOYEE TABLE

IF() FUNCTION:

  • If the value of TRUE or FALSE is omitted, IF treats it as an empty string value (“ ”).
  • Syntax: IF(logical test, Result_If_True, [Result_If_False])
  • Query: Column = IF(EMPLOYEE[SALARY]<10000,” LOW SALARY “,” HIGH SALARY “)
  • Output:
RESULT OF IF FUNCTION

IFERROR() FUNCTION:

  • Syntax: IFERROR(Value,Value_If_Error)
  • Query: Column = IFERROR(25/0,9999)
  • Output:
RESULT OF IFERROR FUNCTION
  • Query: Column = IFERROR(BLANK(),”ERROR”)
  • Output:
RESULT OF IFERROR FUNCTION

TRUE() FUNCTION:

  • Syntax: TRUE()

FALSE() FUNCTION:

  • Syntax: FALSE()
  • The query of TRUE and FALSE function:

Column = IF(EMPLOYEE[ADDRESS]=”MUMBAI”, TRUE(),FALSE())

RESULT OF TRUE AND FALSE STATEMENT

SWITCH() FUNCTION:

  • Syntax: SWITCH()
  • Query: Column = SWITCH( TRUE(),EMPLOYEE[GENDER] =

“FEMALE”, “F”, EMPLOYEE[GENDER] = “MALE”, “M” )

RESULT OF SWITCH FUNCTION

AND() FUNCTION:

  • It accepts only two arguments. If you perform AND operation on multiple series then you can create a series of calculations or use the AND(&&) operator.
  • Syntax: AND(Logical1,Logical2)
  • Query: Column = IF( AND( EMPLOYEE[SALARY] < 10000, EMPLOYEE[ADDRESS] =”MUMBAI”), “MUMBAI”, “FALSE”)
  • Output:
RESULT OF AND FUNCTION

OR() FUNCTION:

  • Syntax: OR(Logical1,Logical2)
  • Query: Column = IF( OR ( EMPLOYEE[SALARY] > 10000, EMPLOYEE[ADDRESS] =”MUMBAI”), “TRUE”, “FALSE”)
  • Output:
RESULT OF OR FUNCTION

NOT () FUNCTION:

  • Syntax: NOT(Logical)
  • Query: Column = NOT EMPLOYEE[EMP_CODE] < 2000
  • Output:
RESULT OF NOT FUNCTION

If you are new to Power BI then must watch below video for better understanding

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store