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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cristianml
Post Prodigy
Post Prodigy

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 !

1 ACCEPTED SOLUTION

@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])

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

6 REPLIES 6
PattemManohar
Community Champion
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])




Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




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 !

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





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Hi @PattemManohar,

 

Sorry I didn't explain myself. Follow the column I refer to. There are some resources that has no information in this "work location", so in those cases also should not be considered.

 

   19-Feb 
NameLevelWork LocationCategoryQuantity
Resource 19 - ConsultantArgentina-Buenos AirHours144
Resource 19 - ConsultantArgentina-Buenos AirCost Rate1,079
Resource 19 - ConsultantArgentina-Buenos AirPayroll155,385
Resource 211 - AnalystArgentina-Buenos AirHours144
Resource 211 - AnalystArgentina-Buenos AirCost Rate766
Resource 211 - AnalystArgentina-Buenos AirPayroll110,274
Resource 211 - Analyst Hours144
Resource 211 - Analyst Cost Rate766
Resource 211 - Analyst Payroll110,274
Resource 310 - AnalystArgentina-Buenos AirHours144
Resource 310 - AnalystArgentina-Buenos AirCost Rate842
Resource 310 - AnalystArgentina-Buenos AirPayroll121,193
Resource 410 - AnalystArgentina-Buenos AirHours0
Resource 410 - AnalystArgentina-Buenos AirCost Rate0
Resource 410 - AnalystArgentina-Buenos AirPayroll0

 

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])

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Thanks !! 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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