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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
hungryhippos1
New Member

Dynamic Average Aging based on DATEDIFF between column date and selected date value

Hi all, I'm trying to figure out how to find the average of a dynamic datediff between a column date field and a selected date value.

 

The idea would be that there is two tables, one that is at an issue level granularity like the following:

Categoryissue idstartdate
IT11/1/2020
IT22/2/2020
HR33/1/2020
HR4

1/4/2020

 

And another that would be a table that has various dates that will be used for slicing purposes.

 

The idea of how this would work is that I would be able to find the DATEDIFF (Days) of each issue id based on the selected date value chosen. From there, I would then aggregate the datediff via an average at the Category level. Something along the lines of:

 

 

=AVERAGE(DATEDIFF(Table1[startdate],SELECTEDVALUE(Table2[date]),DAY))

 

 

 

The big problem is that I don't know how I would properly input the startdate into the measure and get a proper datediff for each row to have it then rollup for the average. Any help would be greatly appreciated!

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @hungryhippos1 

According to your description, you want to calculate the dynamic average value of datediff between the [startdate] and the selected date in Slicer, you can follow my steps:

  1. Create these two measures:
Datediff =

var _selecteddate=SELECTEDVALUE(Table2[Date])

var _datediff=DATEDIFF(MAX('Table1'[startdate]),_selecteddate,DAY)

return

_datediff
Average of datediff = AVERAGEX(values('Table1'[startdate]),[Datediff])
  1. Create a Slicer and place ‘Table2’[Date], a table and place columns like this:

v-robertq-msft_0-1607655812480.png

 

And you can get what you want, like this:

v-robertq-msft_1-1607655812526.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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-robertq-msft
Community Support
Community Support

Hi, @hungryhippos1 

According to your description, you want to calculate the dynamic average value of datediff between the [startdate] and the selected date in Slicer, you can follow my steps:

  1. Create these two measures:
Datediff =

var _selecteddate=SELECTEDVALUE(Table2[Date])

var _datediff=DATEDIFF(MAX('Table1'[startdate]),_selecteddate,DAY)

return

_datediff
Average of datediff = AVERAGEX(values('Table1'[startdate]),[Datediff])
  1. Create a Slicer and place ‘Table2’[Date], a table and place columns like this:

v-robertq-msft_0-1607655812480.png

 

And you can get what you want, like this:

v-robertq-msft_1-1607655812526.png

 

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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