Forum Discussion

cristianml's avatar
cristianml
Post Prodigy
7 years ago
Solved

Countx with multiple filters

Hi,

 

I need to count the quantity of people (resources) from a query. The thing is that it has multiple categories and sometimes there are people in a row that has No activity in that period like the following example with 0 Values. So in this case that resource has not to be considered but the following formula that I tried doesn't work because it considers that line:

 

Quantity Resources = COUNTX(FILTER('Resource Actual','Resource Actual'[Category]="Hours"),'Resource Actual'[Quantity])
 
My solution is to filter by "hours" and then the in the column "Quantity" by > 0  or 1 but not sure how to apply in DAX
 
   Feb-19
NameLevelCategoryQuantity
Resource 19 - ConsultantHours144
Resource 19 - ConsultantCost Rate1,079
Resource 19 - ConsultantPayroll155,385
Resource 211 - AnalystHours144
Resource 211 - AnalystCost Rate766
Resource 211 - AnalystPayroll110,274
Resource 310 - AnalystHours144
Resource 310 - AnalystCost Rate842
Resource 310 - AnalystPayroll121,193
Resource 410 - AnalystHours0
Resource 410 - AnalystCost Rate0
Resource 410 - AnalystPayroll0

 

Any Ideas ?

 

Thanks !

  • cristianml  Not sure whether you want to exclude if they have atleast one "Work Location" as blank or just exlude the rows which have nulls in work location

     

    This will exclude only the blank rows of WorkLocation

     

    Quantity Resources = COUNTX(FILTER('Resource Actual','Resource Actual'[Category]="Hours" && 'Resource Actual'[Quantity]>0 && NOT ISBLANK('Resource Actual'[Work Location])),'Resource Actual'[Name])
    

     

    This will exclude the name completely from the count, if they contain atleast one blank value in Work Location

     

    Quantity Resources = 
    VAR _BlankWL = SELECTCOLUMNS(FILTER('Resource Actual',LEN('Resource Actual'[Work Location])=0),"Name",[Name])
    RETURN COUNTX(FILTER('Resource Actual','Resource Actual'[Category]="Hours" && 'Resource Actual'[Quantity]>0 && NOT 'Resource Actual'[Work Location] IN {_BlankWL} ),'Resource Actual'[Name])
    

     

     

6 Replies

  • PattemManohar's avatar
    PattemManohar
    Community Champion

    cristianml  Try adding another condition in the FILTER as below

     

    Quantity Resources = COUNTX(FILTER('Resource Actual','Resource Actual'[Category]="Hours" && 'Resource Actual'[Quantity]>0),'Resource Actual'[Quantity])
    • cristianml's avatar
      cristianml
      Post Prodigy

      Hi PattemManohar ,

       

      Thanks ! but I realized that I need another condition, a third one. This should be that the column "Work Location" is NOT equal to "" (empty cells) or just the filter by Full cells. 

       

      Is possible to add this ?

       

      Thanks !

      • PattemManohar's avatar
        PattemManohar
        Community Champion

        cristianml I didn't understand that, where is "Work Location" field in the sample data that was provided above.