Forum Discussion

ChrisMajestic's avatar
ChrisMajestic
Frequent Visitor
2 years ago

How to prevent automatic datatype conversion with database connection

I have Power BI Report Server (May 2023) pulling in data from an ODBC connection. One of the fields is a duration field in the format 00:00:00 (hours, mins, secs). Since the numbers look like a time format (20:21:34) Power BI is converting the field to a time field and displaying 8:21:34 pm. I can't for the life of me figure out how to prevent this from happening. When using a database/odbc connection Power BI doesn't appear to add a step that converts the data. It appears to be doing it internally with no way to remove the step or disable it. I've turned off the obvious settings below and it doesn't seem to make a difference.

 

"Type Detection" is set to "Never detect column types and headers for unstructured sources"
"Detect column types and headers for unstructured sources" has been disabled at the file level.
Time Intelligence has been disabled on the global level and the file level

 

Any ideas?

7 Replies

    • ChrisMajestic's avatar
      ChrisMajestic
      Frequent Visitor

      I forgot to mention that I'm simply trying to get it to import as text. The underlying data is a duration but I'm transforming the data to extract days. The data transformation used to work perfectly before it decided to start converting the data to time format. 

      • d_gosbell's avatar
        d_gosbell
        Super User

        ChrisMajestic wrote:

        I forgot to mention that I'm simply trying to get it to import as text. The underlying data is a duration 


        Then you have to add a step doing an explicit cast or conversion to text. Otherwise Power BI will attempt to use the closest compatible data type.