Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello Dear Community,
I'm having trouble with the type automatically assigned by the Power Query Editor (PQE) so I want to force a type depending of the HeaderName.
When it sees the HeaderName in the table below, I want my code to force the type next to it.
When the HeaderName not in the table, I would like the PQE to return its best guess (not necessarely "type any")
I've looked into thew Table.TransformColumnType, which I'm sure it's the way to go but cannot figure it out.
Help needed.
Many thanks.
I would first have power query take the best guess, by setting Automatically detect column types. After that, you do
Table.TransformColumnTypes(PriorStepOrTableName, List.Zip({tblType[HeaderName], tblType[Type]})
You may need to throw some quotes around the HeaderNames, I'm not sure because I'm not at my desk, but the point is to create the list of lists accepted by the function, like {{"HeaderName", type text}, {"AnotherHeader", type number}}
--Nate
@Anonymous , it does not work. Tried with some quotes with the same result.
It is providing me an error.
Any ideas how to modify the code to make it work?
I know that I'm using the code to replace the ColumnHeader and it is working fine. It seems very similar...
#"Replace Cols Names" = Table.TransformColumnNames(#"Promote Header", each Text.Combine(List.ReplaceMatchingItems({_},List.Buffer(List.Zip({tblBeforeAfter[Before],tblBeforeAfter[After]})), Comparer.OrdinalIgnoreCase))),
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 4 |