InterviewSolution
Saved Bookmarks
| 1. |
What is Context? |
|
Answer» Variables are used to STORE values which allocate in Memory and in future which can be used in any kind of calculation. By using variables, we can SIMPLIFY large (2-10 lines of) complex DAX formula into simple chunks which helps anyone easy to read and understand easily. Variables help in prevent WRITING of the same expression again and again. Syntax: VAR <Variable_Name> = Value or Condition RETRUN <Expression>E.g.
Let’s take DAX formula as complex form WITHOUT variables: Salary status = if (EMP[Salary] >10000, "High", if(EMP[Salary] >=5000 || EMP[Salary] <=1000, "Average", if(EMP[Salary]<=5000, "Low") )Let’s take DAX formula using variables in chunks: Salary status = Var High = EMP[Salary]>10000 Var Avg = EMP[Salary]>=5000 || EMP[Salary]<=1000 Var Low = ‘Emp’[Salary]<=5000 Return If (High, "High", if(Avg,”Average”, if(Low,”Low”) ) )The output will be the same for both without and with Variables, however with Variables easy to read and understand the DAX code. |
|