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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Power Query: How to extract first characters from all columns except first two columns in a query

Hi ,

I would like to extract first character from all columns except the first two columns "NAME" and "OBJECT_NAME". I don't wan't to specify the column names each time while extracting since it changes on the basis of period of extracting this report. Currently I can see the code like below. Please help to optimize this code.

Capture1234.PNG

4 REPLIES 4
ImkeF
Super User
Super User

Hi @Anonymous 

is the picture you've posted the desired result? Do you want to change every (but the first 2) column in your table but add a new column that extracts (and combines) the first characters from those columns?

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Hi @ImkeF ,

 

Yes it is.

 

My req is 1) extract first character.

2)calculate the length (which will be 1).

3)replace nulls and errors to 0

4) Add new column with sum of column values against each rows

Hi @Anonymous 

Easiest would be to check the first 2 columns and unpivot others.

Then select first character and do all the other transformation and pivot back.

 

Please check this post on how to improve the quality of your requests: 

 

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

amitchandak
Super User
Super User

@ImkeF , can you help

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.