Forum Discussion

Rsanjuan's avatar
Rsanjuan
Advocate III
9 years ago
Solved

Creating a measure with multiple conditions

I am looking to calculate # of bids, when Job Phase equals certain conditions.  How do we do it for more than one condition?

 

NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),Master[Job.Job_Phase__c]="closed")

 

For example, I want to include not only "closed" but "in process", "confirmed"

 

Thanks!

  • check that the calculated colum is working as expected. Without seeing more of the model its hard to see whats wrong. 

     

     

    //if this is a solution please mark as such

  • Hi Rsanjuan,

     

    You can use the follow DAX expression to get your expected result.
    Count = CALCULATE(DISTINCTCOUNT(Master[ID]),FILTER(ALL(Master),Master[Job.Job_Phase__c]="closed"||Master[Job.Job_Phase__c]="in process"||Master[Job.Job_Phase__c]="confirmed"))

     

     

     

    Regards,

    Charlie Liao

     

     

23 Replies

  • v-caliao-msft's avatar
    v-caliao-msft
    Microsoft Employee

    Hi Rsanjuan,

     

    You can use the follow DAX expression to get your expected result.
    Count = CALCULATE(DISTINCTCOUNT(Master[ID]),FILTER(ALL(Master),Master[Job.Job_Phase__c]="closed"||Master[Job.Job_Phase__c]="in process"||Master[Job.Job_Phase__c]="confirmed"))

     

     

     

    Regards,

    Charlie Liao

     

     

  • samdthompson's avatar
    samdthompson
    Memorable Member

    Hi, the cool thing about calculate is you can put multiple filters after it so:

     

    NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),

    filter(Master[Job.Job_Phase__c])="closed",

    filter(table[1])="condition1",

    filter(table[2])="condition2",

    filter(table[n])="condition_n")

     

    should do the job for you.

     

     

    //if this is a solution please mark as such.

    • Rsanjuan's avatar
      Rsanjuan
      Advocate III

      samdthompson

       

      It seemed to not work. I entered this:

       

      NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),Master[Job.Job_Phase__c]="closed",filter(Master, Master[Job.Job_Phase__c]="confirmed"))

       

      Those conditions are all under the same table and same field "Job Phase".  Am I doing something wrong?

      • samdthompson's avatar
        samdthompson
        Memorable Member

        try this:

         

        NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),

        filter(Master[Job.Job_Phase__c])="closed",

        filter(Master, Master[Job.Job_Phase__c])="confirmed")

         

         

        // if this is a solution please mark as such

  • eka8742's avatar
    eka8742
    Regular Visitor

    How can the result (15 in this case) be sliced versus shown as a static number?

  • Anonymous's avatar
    Anonymous
    Not applicable

    I want to count in datset if NCR status is "Open" and Proposed Action Status, please help

     

    Open & Accepted = CALCULATE(COUNT(NCR[NCR Closeout Status]),NCR[NCR Closeout Status]="Open"&& NCR[Proposed Action Status]="Accepted"))
    • Ashish_Mathur's avatar
      Ashish_Mathur
      Super User

      Hi,

       

      I do not see any mistake in your formula.  What problem are you facing?

      • Anonymous's avatar
        Anonymous
        Not applicable

        The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Bro.. This was solved my requirement...😀