Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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.

Capture.PNG

 

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! 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community 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))

7.png

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.

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community 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))

7.png

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.