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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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