Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Calculate Values for Specific Dates and Phases

Hi all,

 

I would like to be able to calculate the average values for a specific employee, but I need the values to be restricted to a certain date range that starts after "Phase 2". See example data below.

 

For example, I would like to be able to calculate the average "Value" for Employee "01" for the first 30 days of "Phase 2". In this example, only the first 4 values for Employee 01 Phase 2 would be included, since those are included in the 30 days following the first occurrence of Phase 2. 

 

Let me know if more clarification would be helpful, many thanks in advance! 

  • Hi Anonymous 

    Create measures

    start date = CALCULATE(MIN(Sheet6[date]),FILTER(ALLEXCEPT(Sheet6,Sheet6[Employee id]),Sheet6[phase]="phase2"))
    
    first 30 days = [start date]+30
    
    flag = IF(MAX(Sheet6[date])<=[first 30 days]&&MAX(Sheet6[date])>=[start date],1,0)
    
    average = CALCULATE(AVERAGE(Sheet6[value]),FILTER(ALLEXCEPT(Sheet6,Sheet6[Employee id]),[flag]=1))

    Best Regards

    Maggie

     

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

1 Reply

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    Create measures

    start date = CALCULATE(MIN(Sheet6[date]),FILTER(ALLEXCEPT(Sheet6,Sheet6[Employee id]),Sheet6[phase]="phase2"))
    
    first 30 days = [start date]+30
    
    flag = IF(MAX(Sheet6[date])<=[first 30 days]&&MAX(Sheet6[date])>=[start date],1,0)
    
    average = CALCULATE(AVERAGE(Sheet6[value]),FILTER(ALLEXCEPT(Sheet6,Sheet6[Employee id]),[flag]=1))

    Best Regards

    Maggie

     

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