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

Calculate dynamic average age by cuttoff date

Hello,

 

Thanks everyone for taking time to read my post and especially to those who are trying to provide any solution!!

 

Please find the pbix file here: https://drive.google.com/open?id=1EDgaPSgfhTQaQBZcWkIAkJfP5pMS0njz

 

I want to calculate the dynamic average age of outstanding issues based on cutt off date.

outstanding issues are those issues whoese resolved date is after cutt off date.

issue age = [cutt off date] -[created]

 

 

dynamic rolling average 2.JPG

 

The result table is expected to be like this:

dynamic rolling average 3.JPG

 

Below measure is not working. 

average outstanding age = CALCULATE(AVERAGEX(FILTER(ids,FORMAT(ids[created],"yyyy-mm-dd")<FORMAT(MAX(Dates[date]),"yyyy-mm-dd")&&FORMAT(ids[resolved],"yyyy-mm-yy")>FORMAT(MAX(Dates[date]),"yyyy-mm-dd")),DATEDIFF(ids[created],MAX(Dates[date]),DAY)))

1 ACCEPTED SOLUTION

 Hi zxl1031,

 

The return value of "Format" function is text type, so you can't use "Format" function, you should modify your date like pattern 

yyyy\MM\dd HH:mm:ss

And then click Modeling-> Date type to change text type to datetime.

 

Regards,

Jimmy Tao

View solution in original post

7 REPLIES 7
v-yuta-msft
Community Support
Community Support

Hi zxl1031,

 

You should convert column [resolved ] to from text type to date type than use the comparisation condition if your filter. Please check if it can solve your issue.

 

Regards,

Jimmy Tao

Hi Jimmy,

 

Yes, I have converted the format of "resolve" column. But not working.

 

average outstanding age = CALCULATE(AVERAGEX(FILTER(ids,FORMAT(ids[created],"yyyy-mm-dd")<FORMAT(MAX(Dates[date]),"yyyy-mm-dd")&&FORMAT(ids[resolved],"yyyy-mm-yy")>FORMAT(MAX(Dates[date]),"yyyy-mm-dd")),DATEDIFF(ids[created],MAX(Dates[date]),DAY)))

 

Sorry about the typo in the above measure. It is:

average outstanding age = CALCULATE(AVERAGEX(FILTER(ids,FORMAT(ids[created],"yyyy-mm-dd")<FORMAT(MAX(Dates[date]),"yyyy-mm-dd")&&FORMAT(ids[resolved],"yyyy-mm-dd")>FORMAT(MAX(Dates[date]),"yyyy-mm-dd")),DATEDIFF(ids[created],MAX(Dates[date]),DAY)))

 Hi zxl1031,

 

The return value of "Format" function is text type, so you can't use "Format" function, you should modify your date like pattern 

yyyy\MM\dd HH:mm:ss

And then click Modeling-> Date type to change text type to datetime.

 

Regards,

Jimmy Tao

Year-month-year makes no sense...

sorry for the typo....

jthomson
Solution Sage
Solution Sage

How is the user selecting a cutoff date?

Another date table was created for that. 

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.