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
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
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.