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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Convert Text Data type to whole number

(1) Hi Power BI folks, can you assist me in how to convert this text dataype which written in terms of day,hour,minute and second 
     to  seconds because I cannot  use the AVERAGE(V_SLA[Business elapsed time]) measure 
(2) I need to convert it into whole number, find the average and then change the format back to original

 

Business elapsed time.jpg

(3) It returns error when I convert it to duration data type 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Anonymous ,
I have create below column for Hour MIN SEC requirement.
PLease modify it little bit as you have days as well. Incase you are unable to do let me know i will do.
 
REq_Time_Format = IF(SEARCH("sec",'Table'[Time],1,0)>0,SUBSTITUTE(IF(SEARCH("min",'Table'[Time],1,0)>0,SUBSTITUTE(IF(SEARCH("hour",'Table'[Time],1,0)>0,SUBSTITUTE('Table'[Time]," hour ",":"),"00:" & 'Table'[Time])," minute",":"),"00:00:" & 'Table'[Time]),"SEC",""),IF(SEARCH("min",'Table'[Time],1,0)>0,SUBSTITUTE(IF(SEARCH("hour",'Table'[Time],1,0)>0,SUBSTITUTE('Table'[Time]," hour ",":"),"00:" & 'Table'[Time])," minute",":"),"00:00:" & 'Table'[Time]) & "00")
 
then go to modelling tab and convert this column to time format and type: HH:MM:SS:TT
 
then create one more column or you can add calculation in previous formula itself.
 
In_Seconds = 'Table'[REq_Time_Format]*86400
 
then perform your calculations &
 REq_Time_Format is already in your required format so you can display it as it is.
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.
 

View solution in original post

Anonymous
Not applicable

@AnonymousHi, I am getting the following error: DAX comparison operations do not support comparing values of type integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the valueserror.jpg

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,
I have create below column for Hour MIN SEC requirement.
PLease modify it little bit as you have days as well. Incase you are unable to do let me know i will do.
 
REq_Time_Format = IF(SEARCH("sec",'Table'[Time],1,0)>0,SUBSTITUTE(IF(SEARCH("min",'Table'[Time],1,0)>0,SUBSTITUTE(IF(SEARCH("hour",'Table'[Time],1,0)>0,SUBSTITUTE('Table'[Time]," hour ",":"),"00:" & 'Table'[Time])," minute",":"),"00:00:" & 'Table'[Time]),"SEC",""),IF(SEARCH("min",'Table'[Time],1,0)>0,SUBSTITUTE(IF(SEARCH("hour",'Table'[Time],1,0)>0,SUBSTITUTE('Table'[Time]," hour ",":"),"00:" & 'Table'[Time])," minute",":"),"00:00:" & 'Table'[Time]) & "00")
 
then go to modelling tab and convert this column to time format and type: HH:MM:SS:TT
 
then create one more column or you can add calculation in previous formula itself.
 
In_Seconds = 'Table'[REq_Time_Format]*86400
 
then perform your calculations &
 REq_Time_Format is already in your required format so you can display it as it is.
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.
 
Anonymous
Not applicable

Hi @Anonymous 

 

Create one [Days] Column =

Days = IF(FIND("day",'Table'[Time],1,0)>0,LEFT('Table'[Time],FIND("day",'Table'[Time],1,0)-1),"0")
 
Create another column for remaining part=
Remaining_Part = IF(FIND("day",'Table'[Time],1,0)>0,MID('Table'[Time],FIND("day",'Table'[Time],1,0)+4,LEN('Table'[Time])-FIND("day",'Table'[Time],1,0)+4),'Table'[Time])
 
Create time format column 
 
Time Format = IF(SEARCH("sec",'Table'[Remaining_Part],1,0)>0,SUBSTITUTE(IF(SEARCH("min",'Table'[Remaining_Part],1,0)>0,SUBSTITUTE(IF(SEARCH("hour",'Table'[Remaining_Part],1,0)>0,SUBSTITUTE('Table'[Remaining_Part]," hour ",":"),"00:" & 'Table'[Remaining_Part])," minute",":"),"00:00:" & 'Table'[Remaining_Part]),"sec",""),IF(SEARCH("min",'Table'[Remaining_Part],1,0)>0,SUBSTITUTE(IF(SEARCH("hour",'Table'[Remaining_Part],1,0)>0,SUBSTITUTE('Table'[Remaining_Part]," hour ",":"),"00:" & 'Table'[Remaining_Part])," minute",":"),"00:00:" & 'Table'[Remaining_Part]) & "00")
 
After that go to modelling tab and change date type = Time and format =HH:MM:SS:TT
 
and final Second Column/Measure=
In_Seconds = 'Table'[Time Format]*86400+'Table'[Days]*86400
 
 
Capture.PNG
 
 
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.
Anonymous
Not applicable

@AnonymousHi, I am getting the following error: DAX comparison operations do not support comparing values of type integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the valueserror.jpg

Anonymous
Not applicable

Hi @Anonymous 

 

Pleae  check your DAX.

In IF part part when condition is true you are returning interger value(Find() function returns integer position.)

In else part you are returning "0" which is string. So instead of using "0" use 0.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Anonymous
Not applicable

And your DAx is not identical to my dax.

 

Please cross check it again.

Your IF part should compare your condition with 0 not with LEFT(......).

NOTE: FIND( ) and substitute are case Sensitive.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors