Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
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
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
User | Count |
---|---|
60 | |
59 | |
56 | |
38 | |
29 |
User | Count |
---|---|
82 | |
62 | |
45 | |
40 | |
39 |