Forum Discussion

sp8's avatar
sp8
Helper II
7 years ago

direct query automatically changes data type- bug?

Hi. I'm wondering if this is a bug or intentional and if there's a smarter workaround.

 

I have a # of hours column in direct query. Power BI recognizes that it is a number.

Through the query editor, I add a column for # of days. (= # of hours /24)

As soon as I add this column, Power BI automatically converts the data type of both this and the original column to text, even though it does the math just fine.

When I try to do the type conversion in the query editor, it won't let me. I have to do it from the main screen, but I get the potential data loss pop up by doing it that way.

 

Why would it initially recognize a column as a number and then after using it to divide automatically switch it to text?

6 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi sp8 

    I can't reproduce your problem on my side.

    Do you use the lastest version?

    Could you show some screenshots and more other details (eg. code in Advanced editor)?

     

    Best Regards
    Maggie

     

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • sp8's avatar
      sp8
      Helper II

      I'm using the latest version.

      Here is my custom column. It's really simple.

      • v-juanli-msft's avatar
        v-juanli-msft
        Community Support

        Hi sp8 

        Sorry, I still can't reproduce yout problem.

        I can change the data type to number.

        Maybe you can share me with the code to check clearly.

         

        Or you could create a measure directly:

        Measure = SUM('Sheet2$'[amount])/24

         

        Best Regards
        Maggie

         

        Community Support Team _ Maggie Li
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • sp8's avatar
      sp8
      Helper II

      I'm making a custom column, with the formula [days]/24