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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Rename table headers from a SQL Datasource and match current name with a description (lookup)

Dear Community,

 

I'm trying to get help as I intended to use this script: https://www.biinsight.com/a-power-query-custom-function-to-rename-all-columns-at-once-in-a-table/

 

The situation is as follow:

 

I have a PBIX model connected to a locally hosted CRM Database.

The DB has a couple of tables with headers like "G_FICMAINT, SUPP_TIC.." I count around 193 headers per table.

 

The script uses this code here: https://github.com/SoheilBakhshi/PublicRepo/blob/master/Power%20Query%20Rename%20Columns%20Using%20a...

 

The issue I have is that with SQL, I don't have a step: Changed Type

Usually this step calls all table headers and then the function can match and rename headers.

 

How to get the same result from a SQL query ?

I currently have steps:

 

let
Source = Sql.Databases("SQLIPADRESS,2433"),
AKUITEO_TEST = Source{[Name="MASTERDBNAME"]}[Data],
dbo_G_FICMAINT = MASTERDBNAME{[Schema="dbo",Item="G_FICMAINT"]}[Data]
in
dbo_G_FICMAINT

 

Any guidance are welcome!

Thank you

 

Best Regards

Jim

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

 

For DirectQuery, each DirectQuery storage mode table must be based on a Power Query query that can be folded.

 

Relational data source transformations that can be query folded are those that can be written as a single SELECT statement. A SELECT statement can be constructed with appropriate WHERE, GROUP BY, and JOIN clauses. It can also contain column expressions (calculations) that use common built-in functions supported by SQL databases.

 

Generally, the following list describes transformations that can be query folded.

  • Removing columns.

  • Renaming columns (SELECT column aliases).

  • Filtering rows, with static values or Power Query parameters (WHERE clause predicates).

  • Grouping and summarizing (GROUP BY clause).

  • Expanding record columns (source foreign key columns) to achieve a join of two source tables (JOIN clause).

  • Non-fuzzy merging of fold-able queries based on the same source (JOIN clause).

  • Appending fold-able queries based on the same source (UNION ALL operator).

  • Adding custom columns with simple logic (SELECT column expressions). Simple logic implies uncomplicated operations, possibly including the use of M functions that have equivalent functions in the SQL data source, like mathematic or text manipulation functions. For example, the following expressions returns the year component of the OrderDate column value (to return a numeric value).

    powerquery-m
  • Pivoting and unpivoting (PIVOT and UNPIVOT operators).

 

For further information, you may refer to the following document.

Power Query query folding 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

I think this is what you are looking for: Table.ColumnNames - PowerQuery M | Microsoft Docs

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.