Logical DAX Functions in Power BI
Anurodh Kumar
Freelance PowerBI Developer | Analyzing and Visualizing Data with Microsoft Power BI, Grafana and similar tools.
Logical functions in DAX are used to evaluate conditions and return results based on whether those conditions are TRUE or FALSE. These functions help in decision-making within measures and calculated columns.
Common Logical DAX Functions:
1?? IF – Returns one value if a condition is TRUE, otherwise returns another value.
?? Example:
DAX -- IF(Sales[Amount] > 1000, "High", "Low")
?? If sales amount is greater than 1000, it returns "High"; otherwise, it returns "Low."
2?? SWITCH – Evaluates an expression against multiple values and returns a corresponding result.
?? Example:
DAX -- SWITCH(Sales[Category], "Electronics", "High Margin", "Furniture", "Medium Margin", "Other")
?? Returns "High Margin" for Electronics, "Medium Margin" for Furniture, and "Other" for everything else.
3?? AND – Returns TRUE if both conditions are met.
?? Example:
DAX -- AND(Sales[Amount] > 1000, Sales[Region] = "West")
?? TRUE only if Sales amount is above 1000 and the region is "West."
4?? OR – Returns TRUE if at least one condition is met.
?? Example:
DAX -- OR(Sales[Amount] > 1000, Sales[Region] = "West")
?? TRUE if Sales amount is above 1000 or the region is "West."
5?? NOT – Reverses a boolean value (TRUE → FALSE, FALSE → TRUE).
?? Example:
DAX -- NOT(Sales[Amount] > 1000)
?? Returns TRUE for sales amounts ≤ 1000 and FALSE otherwise.
6?? ISBLANK – Checks if a value is blank.
?? Example:
DAX -- IF(ISBLANK(Sales[Amount]), "No Data", Sales[Amount])
?? Returns "No Data" if the amount is blank, otherwise returns the amount.
Data Analyst |Open to work| SQL, Advanced Excel, Python, Power BI,DAX,Power Query ,Tableau | 5+ Projects, Data Cleaning,Data analysis, ETL .4X Top LinkedIn Voice Mis Analyst
1 个月Useful logical functions thanks Anurodh Kumar