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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
punksterz626
Helper II
Helper II

How to calculate Average with DATEDIFF today plus a FILTER

Hello All,

 

Can someone help me formulate a DAX expression for the following criteria. I've tried and for some reason it is not showing what I want

So I have a date column and a category column

 

I want the AVERAGE of days between "date column" date and today with a filter from "category column"

 

Hope someone can help me. Thank you.

1 ACCEPTED SOLUTION
TheoC
Super User
Super User

Hi @punksterz626 

 

Create two calculated columns:

 

Days from Today = TODAY() - 'Table'[Start Date]

The second calculated column as follows:

Average = CALCULATE ( AVERAGEX ( 'Table' , 'Table'[Days from Today] ) , ALLEXCEPT ( 'Table' ,'Table'[Category] ) )

 

Output will be similar to below:

TheoC_0-1643760975926.png

 

Hope this helps 🙂

 

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Create a calculated column formula

Days between = today()-data[Date]

To your Table visual, drag Category and this measure

Average days between = average(data[days between])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
TheoC
Super User
Super User

Hi @punksterz626 

 

Create two calculated columns:

 

Days from Today = TODAY() - 'Table'[Start Date]

The second calculated column as follows:

Average = CALCULATE ( AVERAGEX ( 'Table' , 'Table'[Days from Today] ) , ALLEXCEPT ( 'Table' ,'Table'[Category] ) )

 

Output will be similar to below:

TheoC_0-1643760975926.png

 

Hope this helps 🙂

 

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

@punksterz626, both solutions provided by @Ashish_Mathur and myself will hopefully provide the outcome you're after. However, just to provide an explanation between primary difference between the two solutions is presented in the below table visual:

TheoC_2-1643768614413.png

 

Hopefully this shows the difference between AVERAGEX and AVERAGE as well, in the power the "X" function holds.

 

All the best and hope the above makes sense.

 

Theo 🙂

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Can this be done as a measure or does it have to be calculated columns? If i were to use the result with the Card visual does it matter which average i use?

Hi @punksterz626 

 

Use Calculated columns in this instance as the syntax works. You can certainly use the Card visual. It will just give an average on the entire set of data. But you can then use the Filter pane of the visual to select what filters you want to include or exclude on your categories.

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors