Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I want to calculate the average days it take to complete an order with product type 'Computer'. How can I calculate that in a measure?
This is a sample of my data:
| OrderID | OrderDate | OrderCompleteDate | Product |
| 1 | 1-11-2021 | 5-11-2021 | Computer |
| 2 | 4-11-2021 | 7-11-2021 | Computer |
| 3 | 7-11-2021 | 11-11-2021 | Computer |
Solved! Go to Solution.
@Anonymous
you can create a column and measure
days = DATEDIFF('Table'[OrderDate ],'Table'[OrderCompleteDate ],DAY)
Measure = AVERAGEX(FILTER('Table','Table'[Product ]="Computer"),'Table'[days])
or you can create a measure directly.
Measure 2 =
VAR tbl=ADDCOLUMNS(FILTER('Table','Table'[Product ]="Computer"),"day2",DATEDIFF('Table'[OrderDate ],'Table'[OrderCompleteDate ],DAY))
return AVERAGEX(tbl,[day2])
pls see the attachment below.
Proud to be a Super User!
Hi,
You may create a calculated column formula to calculate the difference between the 2 date columns. Give a heaing to that column as Days. Then write this measure
Measure = average9Data[Days])
To your table visual, drag Product and the Measure.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@Anonymous
you can create a column and measure
days = DATEDIFF('Table'[OrderDate ],'Table'[OrderCompleteDate ],DAY)
Measure = AVERAGEX(FILTER('Table','Table'[Product ]="Computer"),'Table'[days])
or you can create a measure directly.
Measure 2 =
VAR tbl=ADDCOLUMNS(FILTER('Table','Table'[Product ]="Computer"),"day2",DATEDIFF('Table'[OrderDate ],'Table'[OrderCompleteDate ],DAY))
return AVERAGEX(tbl,[day2])
pls see the attachment below.
Proud to be a Super User!
@Anonymous
like @manikumar34 mentioned, just want to differerntiate from the day column in the first solution.
Proud to be a Super User!
@Anonymous ,
days2 is defined here as a column for the difference of those tow date columns. You can use othe column name instaed. One first measure dates difference created as a column whereas on 2nd calculation written as a measure, so he is using variable and ADDCOLUMNS functions to define that on measure and use that on AVERAGEX
Proud to be a Super User!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 28 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |