cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
p6sk
Helper I
Helper I

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, @p6sk 

 

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 III
Super User III

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, @p6sk 

 

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

lbendlin
Super User III
Super User III

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.

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
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.