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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
stvn43
Frequent Visitor

AverageX with Calculated Column and Format function

I created a calculated column to get a time duration value using the Format function, and it looks great, but I can't use AverageX on it because now it's a string value. Is there a way to get this formatting w/out using the Format function to keep the output value to a time-based value?
Here is my DAX for the calculated column and the assoicated mesaure:
Difference =
VAR EditTime =
  IF([editbegintime] <= 0, "00:00:00",
    FORMAT(TimeToEdit[editendtime] - TimeToEdit[editbegintime],"HH:MM:SS"))
Return
EditTime
Time to Caption =
VAR TTC =  
    AVERAGEx(FILTER(TimeToEdit, [service] = "Captioning"), [Difference])
Return
TTC
 
2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @stvn43,

 

You can use the TIME function in DAX to create a duration value instead of using the FORMAT function.

 

Difference = 
VAR EditTime =
  IF([editbegintime] <= 0, TIME(0, 0, 0),
    TimeToEdit[editendtime] - TimeToEdit[editbegintime])
RETURN EditTime

Time to Caption =
VAR TTC = AVERAGEX(FILTER(TimeToEdit, [service] = "Captioning"), [Difference])
RETURN FORMAT(TTC, "HH:MM:SS")

 

By using the TIME function, you can now use the AverageX function on the Difference column because it returns a duration value instead of a string.

 

I hope this helps! Let me know if you have any further questions.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

stvn43
Frequent Visitor

Many thanks, Sahir!

View solution in original post

2 REPLIES 2
stvn43
Frequent Visitor

Many thanks, Sahir!

Sahir_Maharaj
Super User
Super User

Hello @stvn43,

 

You can use the TIME function in DAX to create a duration value instead of using the FORMAT function.

 

Difference = 
VAR EditTime =
  IF([editbegintime] <= 0, TIME(0, 0, 0),
    TimeToEdit[editendtime] - TimeToEdit[editbegintime])
RETURN EditTime

Time to Caption =
VAR TTC = AVERAGEX(FILTER(TimeToEdit, [service] = "Captioning"), [Difference])
RETURN FORMAT(TTC, "HH:MM:SS")

 

By using the TIME function, you can now use the AverageX function on the Difference column because it returns a duration value instead of a string.

 

I hope this helps! Let me know if you have any further questions.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.