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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
aharris15
Helper II
Helper II

Caculating Average for Sum of a Column with Slicers

Hello,

 

I'm trying to calculate the average per Person per Office ID of Direct Labor Time. The formulas I've attempted so far have not yielded the proper results. The idea is to have this measure in a single card and needs to be reactive to the date and Office ID slicers on the page. 

 

Below is a sample of my data. The results that I'd expect is for OH to have an average of 12.5 hours for Direct Labor Time and PA to have an average of 10.25 hours. 

 

Any help is appreciated!

 

NameOffice IDLabor TimeLabor Type
AdamPA2.5Direct
AdamPA1Direct
AdamPA1.25Indirect
AdamPA4.5Direct
AdamPA1.5Indirect
AdamPA1Direct
EricOH0.5Indirect
EricOH0.5Indirect
EricOH5Direct
EricOH1.25Direct
EricOH2.5Direct
EricOH1.5Direct
EricOH1Indirect
EricOH5.75Direct
EricOH4Indirect
EricOH2.25Indirect
IvanPA1Direct
IvanPA6Indirect
IvanPA6.5Direct
IvanPA1Direct
IvanPA5.75Indirect
IvanPA3Direct
IvanPA1Indirect
IvanPA1Indirect
OwenOH3.75Direct
OwenOH1Indirect
OwenOH6Indirect
OwenOH0.5Direct
OwenOH0.75Direct
OwenOH1.5Direct
OwenOH0.5Direct
OwenOH1Indirect
OwenOH2Indirect
JeremyOH3Indirect
JeremyOH6Direct
JeremyOH2.5Direct
JeremyOH0.5Direct
JeremyOH4Direct
JeremyOH1.5Direct
JeremyOH5.5Indirect
JeremyOH0.75Indirect
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @aharris15 ,

 

Check the document about var.

https://docs.microsoft.com/en-us/dax/var-dax 

And check the measures below.

Measure = CALCULATE(DISTINCTCOUNT('Table'[Name]),FILTER(ALLEXCEPT('Table','Table'[Office ID]),'Table'[Labor Type]="Direct"))

Measure 2 = CALCULATE(SUM('Table'[Labor Time]),FILTER('Table','Table'[Office ID]=SELECTEDVALUE('Table'[Office ID])&&'Table'[Labor Type]="Direct"))

Measure 3 = [Measure 2]/[Measure]

Result would be shown as below.

1.PNG

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @aharris15 ,

 

Check the document about var.

https://docs.microsoft.com/en-us/dax/var-dax 

And check the measures below.

Measure = CALCULATE(DISTINCTCOUNT('Table'[Name]),FILTER(ALLEXCEPT('Table','Table'[Office ID]),'Table'[Labor Type]="Direct"))

Measure 2 = CALCULATE(SUM('Table'[Labor Time]),FILTER('Table','Table'[Office ID]=SELECTEDVALUE('Table'[Office ID])&&'Table'[Labor Type]="Direct"))

Measure 3 = [Measure 2]/[Measure]

Result would be shown as below.

1.PNG

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
aharris15
Helper II
Helper II

Help is still needed!!

aharris15
Helper II
Helper II

Still looking for help on this if anyone has any ideas!

aharris15
Helper II
Helper II

Hi @Fowmy 

 

Can you explain your measure a little more. For example, I don't see VAR_T as a function. Also, do you need to fill in anything for the RETURN portion?

 

Sorry - I'm still learning with DAX.

Fowmy
Super User
Super User

@aharris15 

Add the following measure:

Avg per Person per Office ID Direct = 
VAR __T = 
CALCULATETABLE(
    SUMMARIZE(Table7 , Table7[Name], Table7[Office ID] , "__Avg", SUM(Table7[Labor Time])),
    Table7[Labor Type] = "Direct"
)
RETURN
AVERAGEX( __T, [__Avg])

Fowmy_0-1605127393163.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.