Forum Discussion

chris_jones's avatar
chris_jones
New Member
6 years ago
Solved

Counting three text value in a column

Hi,

 

I have one expression that works for only one value but having issues trying to expand it for three.

 

Example - That works for just counting how many times APPLE is listed in the Fruit Column

 

Total Count = CALCULATE ( COUNTROWS ( 'MyData' ), 'MyData[Fruit] = "APPLE" )

 

I want to count how many times, APPLE, PEAR or PLUM are in the same column.

 

Any Help?

  • Hi chris_jones  - use the OR command or the || method

     

    Total Count = 
    CALCULATE ( COUNTROWS ( 'MyData' ), 
      OR('MyData[Fruit] = "APPLE", OR('MyData[Fruit] = "PEAR", 'MyData[Fruit] = "PLUM")))
    
    Total Count = 
    CALCULATE ( COUNTROWS ( FILTER( 'MyData' ), 
      'MyData[Fruit] = "APPLE" || 'MyData[Fruit] = "PEAR" || 'MyData[Fruit] = "PLUM"))
    
    

     

    Either of those should work.

     

    Hope this helps

    David

3 Replies

  • dedelman_clng's avatar
    dedelman_clng
    Icon for Community Champion rankCommunity Champion

    Hi chris_jones  - use the OR command or the || method

     

    Total Count = 
    CALCULATE ( COUNTROWS ( 'MyData' ), 
      OR('MyData[Fruit] = "APPLE", OR('MyData[Fruit] = "PEAR", 'MyData[Fruit] = "PLUM")))
    
    Total Count = 
    CALCULATE ( COUNTROWS ( FILTER( 'MyData' ), 
      'MyData[Fruit] = "APPLE" || 'MyData[Fruit] = "PEAR" || 'MyData[Fruit] = "PLUM"))
    
    

     

    Either of those should work.

     

    Hope this helps

    David