Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count with multiple conditions

Hi, 

 

I have this calculation below but the syntax appears to be incorrect. Any idea how to make this work please?

 

Jobs =
CALCULATE(COUNT(mort[mort_no]), 
(mort[mort_id] = 12), 
(mort[mort_desc] = "Open"), 
(mort[mort_type] = "NEW"), 
YEAR(mort[Date_In])>2017)
  • Anonymous's avatar
    Anonymous
    4 years ago

    Try this:

     

    Jobs =
    CALCULATE (
        COUNT ( mort[mort_no] ),
        (
            mort[mort_id] = 12
            && mort[mort_desc] = "Open" 
            && mort[mort_type] = "NEW"
            && YEAR ( mort[Date_In] ) > 2017
        )
    )

3 Replies

  • smpa01's avatar
    smpa01
    Community Champion

    Anonymous  try this

     

    Measure =
    CALCULATE (
        COUNT ( mort[mort_no] ),
        FILTER (
            SUMMARIZE (
                mort,
                mort[mort_id],
                mort[mort_desc],
                mort[mort_type],
                mort[Date_In]
            ),
            mort[mort_id] = 12
                && mort[mort_desc] = "Open"
                && mort[mort_type] = "NEW"
                && YEAR ( mort[Date_In] ) > 2017
        )
    )
    
  • Anonymous's avatar
    Anonymous
    Not applicable

    Try this:

     

    Jobs =
    CALCULATE (
        COUNT ( mort[mort_no] ),
        (
            mort[mort_id] = 12
            && mort[mort_desc] = "Open" 
            && mort[mort_type] = "NEW"
            && YEAR ( mort[Date_In] ) > 2017
        )
    )
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    I created some data:

    Here are the steps you can follow:

    1. Create measure.

    Measure =
    COUNTX(FILTER(ALL('Table'),'Table'[mort_id]=12&&'Table'[mort_desc]="Open"&&'Table'[mort_type]="New"&&'Table'[Date_IN]>2017),[mort_no])

    2. Result:

     

    Best Regards,

    Liu Yang

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