Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Change Column Values When Filter Is Applied

Hi,   My main goal is to calculate the average of cases closed the employees have per day, but I'm only counting the days they close more than 2 cases.   So, If the date of closure is repeated mo...
  • Anonymous's avatar
    Anonymous
    7 years ago
    -- measure you need first
    
    [# Closed Cases] =
    	DISTINCTCOUNT(
    		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 =
    	COUNTROWS(
    		FILTER(
    			'Calendar'[Date],
    			[# Closed Cases] >= __minNumOfCases
    		)
    	)
    var _totalNumOfCases = [# Closed Cases]
    RETURN
    	if( __onlyOneAnalystVisible,
    		DIVIDE( __totalNumOfCases, __numOforkedDays )
    	)