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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
analyst123
Frequent Visitor

Calculating Average from a measure

Hello,

I have a dataset where I am trying to find the average of a measure to show it as a card on my dashboard. 

I have used the following measure code to get the time duration between two dates: 

 

DOWNTIME (MINUTES) = SUMX('Source', CALCULATE(
DATEDIFF(MIN(Source[APPEARED]), MIN(Source[DISAPPEARED]), MINUTE) +
(SECOND(MIN(Source[DISAPPEARED])) - SECOND(MIN(Source[APPEARED]))) / 60
))
 
I need to calculate the average of this duration based on the count of 'message text'. 
I tried using the following formula:
 
Measure = AVERAGEX(VALUES(Source[MESSAGE NUMBER]), CALCULATE(
DATEDIFF(MIN(Source[APPEARED]), MIN(Source[DISAPPEARED]), MINUTE) +
(SECOND(MIN(Source[DISAPPEARED])) - SECOND(MIN(Source[APPEARED]))) / 60))
 
But it does not give me the accurate value. 
 This is an example of the layout:
analyst123_1-1724941439582.png

 

Here, the average should be 38/23 = 1.65, but instead the average time is 1.25 minutes.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @analyst123 

I create a sample table:

vyohuamsft_1-1725001807544.png

Then create a new measure and try the following DAX expression:

AverageDowntime = 
DIVIDE(
    SUMX(VALUES('Table'[Message number]), CALCULATE(
        DATEDIFF(MIN('Table'[APPEARED]), MIN('Table'[DISAPPEARED]), MINUTE) +
        (SECOND(MIN('Table'[DISAPPEARED])) - SECOND(MIN('Table'[APPEARED]))) / 60
    )),
    DISTINCTCOUNT('Table'[MESSAGE NUMBER])
)

 

Here is my preview:

vyohuamsft_2-1725001877424.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

2 REPLIES 2
Anonymous
Not applicable

Hi, @analyst123 

I create a sample table:

vyohuamsft_1-1725001807544.png

Then create a new measure and try the following DAX expression:

AverageDowntime = 
DIVIDE(
    SUMX(VALUES('Table'[Message number]), CALCULATE(
        DATEDIFF(MIN('Table'[APPEARED]), MIN('Table'[DISAPPEARED]), MINUTE) +
        (SECOND(MIN('Table'[DISAPPEARED])) - SECOND(MIN('Table'[APPEARED]))) / 60
    )),
    DISTINCTCOUNT('Table'[MESSAGE NUMBER])
)

 

Here is my preview:

vyohuamsft_2-1725001877424.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

bhanu_gautam
Super User
Super User

@analyst123 , Try below DAX

 

Average Downtime (Minutes) =
DIVIDE(
    SUMX(
        VALUES(Source[MESSAGE NUMBER]),
        CALCULATE(
            DATEDIFF(MIN(Source[APPEARED]), MIN(Source[DISAPPEARED]), MINUTE) +
            (SECOND(MIN(Source[DISAPPEARED])) - SECOND(MIN(Source[APPEARED]))) / 60
        )
    ),
    COUNTROWS(VALUES(Source[MESSAGE NUMBER]))
)



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.