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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sp8
Helper II
Helper II

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 6
v-juanli-msft
Community Support
Community Support

Hi @sp8 

Do you add a custom column or a conditional column?

 

Best Regards
Maggie

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

v-juanli-msft
Community Support
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.

I'm using the latest version.

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

errorcapture.JPG

Hi @sp8 

Sorry, I still can't reproduce yout problem.

I can change the data type to number.

1.png

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.

Sorry if I wasn't clear. I can manually change it to number type.  My only issue is with the automatic behavior.

I'm saying that when I connect to the table, the type is number and then when I add the new (/24) column, PBI automatically changes the type from number to text. This is why I have to manually change it.

But that doesn't make sense as it was a number type before, and then I did a number function to it (division), so why would it change to  a text type after that?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.