Forum Discussion
Anonymous
4 years agoNot applicable
Average - Group by calculation
Hi, I am trying to calculate average and I am trying to calculate measure which will return the following: We have some workers and I would like to calculate a measure in DAX which will return...
- 4 years ago
Hi,
you can use this measure
%WTofWorker/AvWTbyDept = var WTbyDept = CALCULATE([WTofWorker],ALL('Work'[WorkerTable.Worker]))var NrofWorkerbyDept = calculate(count('Work'[WorkerTable.Worker]),all('Work'[WorkerTable.Worker]))var AvWTbyDept = DIVIDE(WTbyDept, NrofWorkerbyDept)var Perc = if (HASONEVALUE('Work'[WorkerTable.Worker]), DIVIDE([WTofWorker],AvWTbyDept))returnPerc(you can divide the formula in many steps)
If this post is useful to help you to solve your issue consider giving the post a thumbs up
and accepting it as a solution !
serpiva64
4 years agoSolution Sage
Hi,
you can use this measure
%WTofWorker/AvWTbyDept = var WTbyDept = CALCULATE([WTofWorker],ALL('Work'[WorkerTable.Worker]))
var NrofWorkerbyDept = calculate(count('Work'[WorkerTable.Worker]),all('Work'[WorkerTable.Worker]))
var AvWTbyDept = DIVIDE(WTbyDept, NrofWorkerbyDept)
var Perc = if (HASONEVALUE('Work'[WorkerTable.Worker]), DIVIDE([WTofWorker],AvWTbyDept))
return
Perc
(you can divide the formula in many steps)
If this post is useful to help you to solve your issue consider giving the post a thumbs up
and accepting it as a solution !
- Anonymous4 years agoNot applicable
Hi serpiva64,
One more question - your solution is brilliant - how should I take care of when we have workers where there are no value regarding the working time and how did you define the"WTofWorker" variable?
Thanks!- serpiva644 years agoSolution Sage
Sorry
WTofWorker = sum('Work'[Working time of the Worker])regarding the first question i think you have to count number of worker of each department not from the fact table but from the dimension table (if you have otherwise you have to create it)
- AliceW3 years agoPower Participant
Brilliant solution, Serpiva! Thank you!