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
filarap
Helper III
Helper III

Unpivot - [DataFormat.Error] We couldn't convert to Time

Hi All,

 

I am strugling with an error OLE DB or ODBC error: [DataFormat.Error] We couldn't convert to Time.

 

I already tried solutions from below, but it did not work

 

https://community.powerbi.com/t5/Desktop/DataFormat-error-We-couldnt-convert-to-Number/td-p/61492

https://community.powerbi.com/t5/Desktop/Error-DataFormat-Error-We-couldn-t-convert-to-Number-Detail...

 

I have interactions with duration, and what i am trying to achieve is to split this time into 30 min time buckets, which i suceeded, but had to create column for each bucket.

After i did it, i tried using unpivot in order to get data in format that i need for going forward.

 

However once i apply this, i get the error above. Below is query i made. Time buckets i had in format "08:00" as well, data type time, but same thing once apply.

State of query now:

pbi unpivot.JPG

 

Please help

Filarap

 

1 ACCEPTED SOLUTION

Thank you for the attempt.

 

I managed to find the issue. 
4 errors that happend in column that was supposed to be time value. Calculation in that column caused cells to be over 1, immediatelly preventing it to be converted to time. Once i fixed these errors, unpivot worked like a charm 🙂

 

I realy appreciate your asistance.

Regards

Filarap

View solution in original post

4 REPLIES 4
d_gosbell
Super User
Super User

Rather than fighting with pivot/unpivot it might be easier to look at this a different way. To round down a time to the nearest 30 minute boundary you could use a custom column like the following in your PowerQuery

 

Duration.From(Number.RoundDown(Duration.TotalMinutes([Duration])/30)/48)

 

where the 30 indicates the size of the buckets you want to create and the 48 is the number of those "buckets" in a day. So you could change these 2 numbers to 15 and 96 to round down to the closest 15 minute interval.

Thank you d_gosbell,

 

I already have 30 minute buckets created. Sorry dont have access to file at the moment, so i will replicate in table below.

Table below shows data before i did unpivot (Screenshot from initial post). 

 

Duration(min)Starting Time stampEnding Time StampStarting BucketEnding Bucket15:0015:3016:0016:30
4815:3216:2015:3016:00028200

 

Starting time stamp is taken from date/time cell from raw data.

I have create columns showing exact time spent in each interval. This was done using nested ifs.

 

No issue with apply before unpivot. As soon i do unpivot, and try to apply, i get error above. 

 

Or am I misunderstanding your formula? 

 

Regards

Filarap

Oh I thought your raw data was different.

 

But i'm not able to replicate your error. I pasted your example data into a new Power BI report, selected all the columns that were not time buckets then chose the UnPivotOtherColumns transformation which produced the PowerQuery step below

 

Table.UnpivotOtherColumns(#"Changed Type1", {"Duration(min)", "Starting Time stamp", "Ending Time Stamp", "Starting Bucket", "Ending Bucket"}, "Attribute", "Value")

 

This unpivoted the example data without an error. Are you able to share some example data (does not have to be real data) which reproduces your issue.

 

ps. Sorry for the late reply it appears that the forum notifications have stopped working

Thank you for the attempt.

 

I managed to find the issue. 
4 errors that happend in column that was supposed to be time value. Calculation in that column caused cells to be over 1, immediatelly preventing it to be converted to time. Once i fixed these errors, unpivot worked like a charm 🙂

 

I realy appreciate your asistance.

Regards

Filarap

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.