Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
san_bxl
New Member

Multiple OR condtions within calculate

I have to write a DAX which filters data from three connected tables.
table 1. Project Resource Assignemnet
table 2.Project Resource
table 3,Project_activity

I need to now get a sum from Resource Assignement  and have multiple conditons 1 ,2 and 3
Between these i need to have OR and Condition 2 and 3 i need a AND within it

M11-
2a_Scope =
CALCULATE(
    SUM('Project-Resource Assignment'[PlannedUnits]),
    ALL('DATE TABLE'),
   
    -- condition 1
    'Project-Resource'[Id] IN {
        "C3-GAD-14",  
        "C3-GAD-12",  
        "C3-GAD-13",  
        "C3-GAD-11",  
        "C3-GAD-2",  
        "C3-GAD-1",  
        "C3-GAD-7",  
        "C3-M-9"    
    } ||

-- condition 2
    (
        'Project-Resource'[Id] = "C3-M-102" &&
        LEFT('Project-Activity'[Id], 14) = "CM-"
    ) ||

    --
-- condition 2
    (
        'Project-Resource'[Id] = "C3-M-88" &&
        LEFT('Project-Activity'[Id], 14) = "CM-S3"  
    )
)


## the above code doesnt work

5 REPLIES 5
Poojara_D12
Super User
Super User

Hi @san_bxl 

Your DAX formula has logical flaws that prevent the CALCULATE function from interpreting the conditions as intended. Specifically, the logical OR (||) and AND (&&) operations must be properly nested, and the filter syntax needs to conform to the DAX filter context structure.

 

Here’s the corrected DAX formula:

 

M11-2a_Scope =
CALCULATE(
    SUM('Project-Resource Assignment'[PlannedUnits]),
    ALL('DATE TABLE'),
    
    // Condition 1
    OR(
        'Project-Resource'[Id] IN {
            "C3-GAD-14",  
            "C3-GAD-12",  
            "C3-GAD-13",  
            "C3-GAD-11",  
            "C3-GAD-2",  
            "C3-GAD-1",  
            "C3-GAD-7",  
            "C3-M-9"
        },

        // Condition 2 AND Condition 3
        AND(
            'Project-Resource'[Id] = "C3-M-102",
            LEFT('Project-Activity'[Id], 14) = "CM-"
        ),

        AND(
            'Project-Resource'[Id] = "C3-M-88",
            LEFT('Project-Activity'[Id], 14) = "CM-S3"
        )
    )
)

 

This formula should now calculate the sum of PlannedUnits with the specified conditions applied correctly.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

I am looking for
condition 1 or Condition 2 or Conditon 3
If it satisfies any, its should calculate

Hi @san_bxl ,

 

You calculation is based on your data model.  We need to know the relationship in your report and what your table looks like.
Could you share a sample file with us and then show us a screenshot with the result you want? This will make it easier for us to find the solution.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@San_Raz 

Can you try this dax:

M11-2a_Scope =
CALCULATE(
    SUM('Project-Resource Assignment'[PlannedUnits]),
    ALL('DATE TABLE'),
    
    // Combine Condition 1, 2, and 3 with OR logic
    OR(
        // Condition 1
        'Project-Resource'[Id] IN {
            "C3-GAD-14",  
            "C3-GAD-12",  
            "C3-GAD-13",  
            "C3-GAD-11",  
            "C3-GAD-2",  
            "C3-GAD-1",  
            "C3-GAD-7",  
            "C3-M-9"
        },

        // Condition 2
        AND(
            'Project-Resource'[Id] = "C3-M-102",
            LEFT('Project-Activity'[Id], 14) = "CM-"
        ),

        // Condition 3
        AND(
            'Project-Resource'[Id] = "C3-M-88",
            LEFT('Project-Activity'[Id], 14) = "CM-S3"
        )
    )
)

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
johnt75
Super User
Super User

In both LEFT functions you are taking 14 characters, I think you meant to only take 4.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.