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

View all the Fabric Data Days sessions on demand. View schedule

Reply
BTRD
Frequent Visitor

measure = AVERAGEX(DATEDIFF(DateA, DateB, DAY)) does not work.

Hi everybody,

 

I have 2 colonnes says DateA and DateB with date format. If I create another C Column = DateA -DateB, it works.

I have many average date difference to calculate,  so I would like to create Measures instead of Columns.

But I can't get this result.

When I use Measure = datediff(, I can't use columns, I understand that it doesn't know what level I am, I need to use an agregation like min() ?

Can someone please help me understand why it doesn't work. I want to make a calculation like :
measure = AVERAGEX(DATEDIFF(DateA, DateB, DAY))

 

Thanks in advance,

 

1 ACCEPTED SOLUTION
BeaBF
Super User
Super User

@BTRD Hi! 

The main issue is that Measures operate in an aggregated context. The DATEDIFF function expects specific date values, but Measures don't know which rows to calculate on unless you use aggregations or iterate over the table using functions like AVERAGEX.

you can use this measure:

Measure =
AVERAGEX(
YourTableName,
DATEDIFF(YourTableName[DateA], YourTableName[DateB], DAY)
)

 

if you provide me sample data and the expected result i can help you.

 

BBF

View solution in original post

2 REPLIES 2
BTRD
Frequent Visitor

Hi BeaBF, thanks a lot for your explanation and help ! It works perfectly, yes !

BeaBF
Super User
Super User

@BTRD Hi! 

The main issue is that Measures operate in an aggregated context. The DATEDIFF function expects specific date values, but Measures don't know which rows to calculate on unless you use aggregations or iterate over the table using functions like AVERAGEX.

you can use this measure:

Measure =
AVERAGEX(
YourTableName,
DATEDIFF(YourTableName[DateA], YourTableName[DateB], DAY)
)

 

if you provide me sample data and the expected result i can help you.

 

BBF

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.