Languages Advisor | DAX

DAX Compliance Checker for Meetings

This guide details a DAX solution to check compliance based on specific conditions: the month being January, February, or March and exactly one meeting held, returning "Compliant" or "Non-Compliant".


Empty image or helper icon

This Query related with thread "DAX Compliance Checker for Meetings "

Prompt

if month is January or February or March AND meetings = 1 then Compliant

Answer

DAX Solution for Compliance Check

To address your requirement, we need to verify if the month is January, February, or March, and if the number of meetings is equal to 1. If these conditions are met, the output should indicate "Compliant".

Steps to Create the Measure

  1. Check the Month: Use DAX functions to extract the month from your date column.
  2. Check the Number of Meetings: Ensure that the number of meetings equals 1.
  3. Return Compliance Status: Combine these checks to return "Compliant" or "Non-Compliant".

This can be accomplished using a DAX measure.

DAX Code

Below is the code snippet to create the measure:

Compliance Status = 
VAR CurrentMonth =
    MONTH([Date])
VAR MonthsInRange =
    CurrentMonth = 1 || CurrentMonth = 2 || CurrentMonth = 3
VAR IsMeetingCompliant =
    [Meetings] = 1
RETURN
    IF(
        MonthsInRange && IsMeetingCompliant,
        "Compliant",
        "Non-Compliant"
    )

Explanation

  1. Extract Current Month:

    • MONTH([Date]): Extracts the month from the date field.
  2. Validate Month:

    • CurrentMonth = 1 || CurrentMonth = 2 || CurrentMonth = 3: Checks if the extracted month is January, February, or March.
  3. Check Meeting Compliance:

    • [Meetings] = 1: Ensures that the number of meetings is equal to 1.
  4. Combine Conditions and Return Result:

    • IF(MonthsInRange && IsMeetingCompliant, "Compliant", "Non-Compliant"): If both conditions are met, it returns "Compliant", otherwise "Non-Compliant".

Best Practices

  1. Variable Usage: Using variables (VAR) improves performance and readability.
  2. Logical Checks: Use logical operators (|| for OR, && for AND) to combine conditions.
  3. Return Readable Results: Ensure the final output is user-friendly.

Conclusion

By following the steps and code provided above, you can create a measure in DAX that checks if the month is January, February, or March and if the number of meetings equals 1, then returns "Compliant". Utilize these techniques for efficient and readable DAX code.

For more advanced and comprehensive learning in DAX and Power BI, consider exploring the Enterprise DNA Platform.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This guide details a DAX solution to check compliance based on specific conditions: the month being January, February, or March and exactly one meeting held, returning "Compliant" or "Non-Compliant".