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 August 31st. Request your voucher.

Reply
Sagimore88
Frequent Visitor

Days between two dates average for a customer orders.

Hello,

Sorry very new to this and trying to help migrate(recreate ssrs reports to PowerBI) - All data is pulled in from the SQL server.

 

I have a [Customer Name] column and a measure with the total number of orders for each customer.

The table contains two date columns - [Recieved Date] and [Effective Date]

 

I am looking to create a measure that simply shows the avg days between the Rec Date and Eff Date across all the customers orders and call it Avg. Lag Time.

 

Customer Name        Total Orders     Avg Lag Time

Smith & Smith           100                  30

 

Thanks for any help. I have search the forums but am finding similiar request that are doing more than I need.

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Sagimore88 

please try

Avg Lag Time =
AVERAGEX (
    TableName,
    DATEDIFF ( TableName[Recieved Date], TableName[Effective Date], DAY )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Sagimore88 

please try

Avg Lag Time =
AVERAGEX (
    TableName,
    DATEDIFF ( TableName[Recieved Date], TableName[Effective Date], DAY )
)

Thank you!

That works but seems to give me the avg lag time of all orders vs giving me the average for the values in the row.

Customer   Orders  Avg Lag time

Smith          12         39.4

Johnson       1          39.4

 

Customer and Order are in the same table the two dates i'm averaging are in a different table. 

I feel like the results for avg  are not taking into account the data from the other two columns.

Thanks Again, Ill keep trying 

 

 

@Sagimore88 

What are the relationships between thses tables? Can you share a screenshot of your data model?

Thanks that question made me look- I had to change the cross filter on the tables in modeling to 'Both' - 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.