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
SteCra100
Helper I
Helper I

Create an "AverageDay" measure

Hello folks.

 

I have a column called “DaysBetween” that calculates the days between two date columns in my table:

 

TableName[StartDate] and TableName[EndDate].

 

My date range starts from 19/04/2019 to the present day.

 

I want to create an Average Days measure that calculates how many weekdays it took to complete a task(s), but only display the average. I also just want to record the data from 01/04/2020 onwards.

 

For example, if 700 tasks have been completed, I want to get the average number of weekdays it took to complete the tasks.

 

I have created an “AverageDays” measure (see below):

 

AverageDays = CALCULATE(AVERAGE(TableName[DaysBetween]), all(TableName[EndDate])

 

However, the above measure calculates the average over my entire dataset, I just want the average to start from 1st April 2020.

 

Can this be done?

 

Many thanks,

1 ACCEPTED SOLUTION

Hi @SteCra100 ,

 

DATESYTD(<dates> [,<year_end_date>])

You may try:

IF(MAX(Table1[InsertDateColumbNameHere].[Date])>"01/04/2020",
CALCULATE(AVERAGE(Table1[InsertColumnNameHere]), DATESYTD( Table1[InsertDateColumbNameHere].[Date])))

 

Best Regards,
Liang
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

4 REPLIES 4
amitchandak
Super User
Super User

@SteCra100 , refer 2nd page , working date diff of the attached file after signature if that can help

 

Hello @amitchandak 

 

Many thanks for your quick reply. I'm afriad I can't downlaod your .phix file as it says i'm not on the correct version. Are you able to guide me what measure you used?

 

Many thanks,

Hello @amitchandak 

 

I have been looking into this more, and I have used the following syntax:

Avg(2) = CALCULATE(AVERAGE(Table1[InsertColumnNameHere]), DATESYTD( Table1[InsertDateColumbNameHere].[Date], "01/04/2020 00:00:00"))
 
Do you think the above would work? I'm not getting any errors when using the measure and I'm getting, what I belive, is the correct result. I just what to make sure if I'm using DATESYTD function correctly.
 
Many thanks,

Hi @SteCra100 ,

 

DATESYTD(<dates> [,<year_end_date>])

You may try:

IF(MAX(Table1[InsertDateColumbNameHere].[Date])>"01/04/2020",
CALCULATE(AVERAGE(Table1[InsertColumnNameHere]), DATESYTD( Table1[InsertDateColumbNameHere].[Date])))

 

Best Regards,
Liang
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.