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
Anonymous
Not applicable

Rename columns when using Direct Query

I scoured the forums today and found various commentary on renaming columns when using Direct Query mode.

 

Some folks say it's possible:

https://community.powerbi.com/t5/Desktop/Rename-columns-in-Power-BI-in-Direct-Query-mode-and-Changin...

 

Some folks say it cannot be done:

https://community.powerbi.com/t5/Desktop/PowerBI-Desktop-Rename-COlumn-FAILS-on-First-attempt-100-of...

 

Unfortunately -- none of the answers appear definitive...especially in terms of data source (i.e. SQL Server vs Oracle).

If one is using DirectQuery in Desktop Version: 2.87.762.0 64-bit (November 2020), is there a way to change column names when using Direct Query?

 

THANKS!

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

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
Allan

 

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

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

The Italians have fantastic videos that dive into the nuts and bolts of the composite model. 

https://www.sqlbi.com/

https://www.youtube.com/watch?v=9lkVk4t2qL0

 

 

v-alq-msft
Community Support
Community Support

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
Allan

 

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

If you are desperate there is a dirty trick - you can now create new columns in Direct Query mode. Those new columns will be stored in a local corner of the data model, and recomputed on each query.  Create a new column with the name you want, then assign it the value of the column from the source data.

Anonymous
Not applicable

Sounds interesting...I'm such a newb...is there a pbix file or some other resource I can consult for details?

Thanks!

 

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.