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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
laurent_rio
Helper I
Helper I

How to make filter with select all work for this case ?

Hi,

 

I have table that have employee name, position, department and training hours 1.JPG

Now i already create several measures 

Total Employee = DISTINCTCOUNT('Training Table'[Employee])
Training Duration = SUM('Training Table'[Training Hours])
Average Training Hours/Staff = DIVIDE('Training Table'[Training Duration],[Total Employee])

And i also want to have table with each department average training hours/staff. I make measure like this 
Department Average Duration/Staff = CALCULATE([Average Training Hours/Staff],filter(allselected('Training Table'),'Training Table'[Department]=MAX('Training Table'[Department] )))

It work when using filter with single selection 
2.JPG
But now i want if i select all in the filter or multiple selection in the filter, the column department average duration/staff also show constant value 
Formula still = average duration/staff = total hours/total employee and it doesnt work with DAX that i use above 
3.JPG
Anyone can help with the DAX ? 
I also upload the sample file for easy reference 
 
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@laurent_rio 

You could also do it like this.

 

Department Average Duration/Staff 2 = 
IF (
    NOT ISBLANK ( [Total Employee] ),
    CALCULATE ( [Average Training Hours/Staff], ALLSELECTED ( 'Training Table' ) )
)

jdbuchanan71_0-1621477934251.png

 

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

@laurent_rio 

You could also do it like this.

 

Department Average Duration/Staff 2 = 
IF (
    NOT ISBLANK ( [Total Employee] ),
    CALCULATE ( [Average Training Hours/Staff], ALLSELECTED ( 'Training Table' ) )
)

jdbuchanan71_0-1621477934251.png

 

 

Ashish_Mathur
Super User
Super User

Hi,

This measure works

Measure = if(ISBLANK([Training Duration]),BLANK(),CALCULATE([Average Training Hours/Staff],ALLSELECTED(Department[Department]),all('Training Table'[Position])))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@laurent_rio , That means it is not using department filter in context

Try measure like

Department Average Duration/Staff = CALCULATE([Average Training Hours/Staff],filter(allselected('Training Table')))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors