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
Anonymous
Not applicable

Convert Text to Number using Direct Query

Hello!

 

Looking for some help with a text column and Direct Query.  I have a column called "Talking" that is the total amount of time spent talking for a user.  The column in table is storing the data as text (for example, 04:57:00).  I'm strugling to get this converted to a number or duration via Direct Query.  I also struggle to convert once I bring into Desktop.  I'm ultimately trying to get an Average Talk time per call (I have another column that has total calls as a number).

 

Any ideas or help would be fantastic.

 

Thanks

 

Mike

3 REPLIES 3
Anonymous
Not applicable

Hi Mike - 

 

First off, as you know the data is treated as text because of the : in there.

 

1. If this needs to be done in DirectQuery itself then it needs to use some kind of Split function in the query, like STRING_SPLIT in SQL Server for example.

 

2. Alternatively you can get the data of "Talking" as Text to PowerBI perform the following steps in Modeling:

   a. Add a new column with the following code for hours:  hours = PATHITEM(SUBSTITUTE('Table'[Talking], ":", "|"), 1)
   b. Add another new column with the following code for minutes: mins = 
hours = PATHITEM(SUBSTITUTE('Table'[Talking], ":", "|"), 2)
   c. Then for seconds: 
hours = PATHITEM(SUBSTITUTE('Table'[Talking], ":", "|"), 3)

3. Once the above is completed you can change the data type for all the above columns into number
4. Once that is done, You can use the following to get overall seconds of talking in another new column:
    
TotalSecsTalked = (('Table'[hours]*60)*60) + ('Table'[Mins] * 60) + 'Table'[secs]


If the above helped your situation, please help mention this as a solution, if not please let me know. Hope this helps.

Regards
Eswar

Anonymous
Not applicable

Hi Eswar

 

Thanks for the reply.  When creating the new column I'm getting the below error:

 

Function 'PATHITEM' is not allowed as part of calculated column DAX expressions on DirectQuery models.

 

Not really sure where to go from here.

 

Thoughts?

 

Thanks

 

Mike

 

Anonymous
Not applicable

Hi Mike - 

 

Can you please share your file for me to look at?

By the way I am using the latest version of PowerBI Desktop for this, may I know what version are you using?

 

Regards

Eswar

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.