Showing results for 
Search instead for 
Did you mean: 
P7GOMES Frequent Visitor
Frequent Visitor

Calculate Average with Filter

Hi, I'm very new to power BI and been doing well so far, but I'm stuck on the following subject:


I'm trying to calculate the average of cases closed by analists by worked day, but I only want to consider "Worked day" when the analist has closed 2 or more cases.



- Date of Closure

- Analist Name

- Case ID (Each case has a unique ID)


The problem is: I dont want to exclude the cases closed on Non Worked Days




In 30 days, a Analist has closed 130 cases

But, in the first 20 days, he closed 6 per day (Literally, not on average), 120 in total

In the last 10, he closed 1 per day (Again, not on average), 10 in total


So we would consider only 20 worked days, but I dont want to ignore the 10 cases closed on the non worked days.


Basically, I would want the average by day being 130 cases in 20 days.


Hope the message was not to confusing.


Thank You

Super User
Super User

Re: Calculate Average with Filter

Say only one analyst is visible in the current context. Then, the calculation would be:


-- measure you need first

[# Closed Cases] =
		FactTable[Case ID]

-- 'Calendar' must join to the FactTable on a Date field 
-- (the other field is [Date Of Closure]
-- and be designated as Date Table in the model. Please make
-- sure you follow the rules of creating a proper Calendar.
-- Without a good calendar a model is almost worthless and
-- prone to errors.

[Analyst Average] :=
var __onlyOneAnalystVisible = HASONEFILTER( FactTable[Analyst Name] )
var __minNumOfCases = 2
var __numOfWorkedDays =
			[# Closed Cases] >= __minNumOfCases
var _totalNumOfCases = [# Closed Cases]
	if( __onlyOneAnalystVisible,
		DIVIDE( __totalNumOfCases, __numOfWorkedDays )

If you'd like to adjust it for a set of analysts, then you'd have to define the logic of what you mean by a daily average for a set of analysts.




Helpful resources

New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)