Forum

Selecting "Any" Dat...
 
Notifications
Clear all

Selecting "Any" Data Type - Misapplied Data Types

2 Posts
2 Users
0 Reactions
631 Views
(@paparob)
Posts: 5
Active Member
Topic starter
 

Power Query usually does a really good job selecting the data type automatically for us.  However, when it misses on a mixed column, I need to force it back to the intended data type.  That's easy for most data columns, but when you want that elusive "ABC, 123" (Any) data type, i do not see a way to revert it back.

Here is a column that I used Excel to calculate the time it took us to close a "Hold" (time to fix a non-conformance of some kind).  Some columns will calculate to a value (as the hold is closed) while others will calculate to "Open" as the hold is still open.

I suppose I could calculate to "Today's Date" or even allow it to force the numbers to text and re-classify them with isnumber later, but I'd rather keep my formula as is, since i further use this column to feed a dashboard in several different ways.

As of now, when I hand off the sheet to Power BI, it sees the text as an error, and stops the data from loading to my Data Warehouse.

So, any takers??  How do we get PQ to classify this as "Any"?

[Image Can Not Be Found][Image Can Not Be Found]

 
Posted : 13/03/2024 2:23 pm
Riny van Eekelen
(@riny)
Posts: 1185
Member Moderator
 

The image you intended to upload doesn't show, but I guess that you added the duration column by selecting the Hold and Start columns and then 'Subtract days' under the 'Date' icon in the user interface. Then you probably added som code to return "Open" in case Hold is empty.

You probably ended up with M-code looking like this:

Table.TransformColumnTypes(Table.AddColumn(#"Previous Step", "Subtraction", each if [Hold] = null then "Open" else Duration.Days([Hold] - [Start])), {{"Subtraction", Int64.Type}})
 
The red bolded code forces the column to be a number (123). Remove it and the column type will be ABC-123 and accepts both text and numbers again.
 
Posted : 14/03/2024 2:59 am
Share: