Forum Discussion

BrianNeedsHelp's avatar
BrianNeedsHelp
Icon for Resolver I rankResolver I
1 year ago
Solved

DAX Summarize By Employee With Formula

I have a table like this that computes the Quota Impact by this formula.  ([Quota]/([Days in Month]*8))*[Hours Closed].  It works fine when all the rows of the table are selected in the Visual.  However I'm trying to group this by Employee, but it sums the Quota Amount for each location and then computes, which is expected, but I'm not certain how to calculate it something like [Quota] divided by Count by Location given there could be an entry in two different months .   Summary it should look like this Bob =44/248 * 16:  
Emp  Quota Impact      
Bob    2.82

Suzy   1.04

 

Instead I get :  Bob=88/248 * 16:

Emp  Quota Impact
Bob    5.67 

Suzy   2.08

 

LocationQuotaDateHours ClosedEmpQuotaImpact
Location A 449/1/20248Bob1.41
Location A 449/1/29248Bob1.41
Location B 129/1/20248Suzy0.38
Location C 139/1/20248Suzy0.41
Location C 1610/1/20244Suzy0.25
  • Quota Impact =

    VAR Granularity =
    SUMMARIZE(
        InputTable,
        InputTable[Emp],
        InputTable[Location],
        InputTable[Date],
        InputTable[Quota]
    )

    RETURN
    SUMX(
        Granularity,
        VAR HoursClosed = CALCULATE(SUM(InputTable[Hours Closed]))
        VAR DaysInMonth = 31  /* DAY(EOMONTH([Date], 0)) */
        RETURN [Quota] / (DaysInMonth * 8) * HoursClosed    
    )

2 Replies

  • Quota Impact =

    VAR Granularity =
    SUMMARIZE(
        InputTable,
        InputTable[Emp],
        InputTable[Location],
        InputTable[Date],
        InputTable[Quota]
    )

    RETURN
    SUMX(
        Granularity,
        VAR HoursClosed = CALCULATE(SUM(InputTable[Hours Closed]))
        VAR DaysInMonth = 31  /* DAY(EOMONTH([Date], 0)) */
        RETURN [Quota] / (DaysInMonth * 8) * HoursClosed    
    )