Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I'm trying to clean up data that comes in ugly. Here is a sample:
DATE [space] multiplier [space] Description [hard return]
Value [hard return]
Repeat from here.
So, every two rows should actually be one row. I can split on the space delimiter to get my first 3 columns, but then, I can't get any farther. I have tried pivoting, but nothing seems to work.
I can make it work if I manually put the data in Word first and replace every other hard return with a space, but that really negates the idea of "automation."
I'd appreciate any and all help. I'm fairly decent with the GUI, but have only read M, haven't written any yet. I know SQL, DAX, and MDX, so it is only a matter of practice and time for M.
Solved! Go to Solution.
You can use this function: https://github.com/ImkeF/M/blob/master/Library/Table.PivotSingleColumn.pq
Just make sure that you get rid of the excess column name-rows. Your table must only contain values that shall go into the new columns.
In the 1st parameter you reference your table and in the 2nd you enter the number of new columns (2 or 4 according to your examples).
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
Actual sample data would help tremendously. For hard M problems @ImkeF is a genius.
I'm sorry, I don't see the option to attach files here, but you can find the sample file at https://www.dropbox.com/s/rwp61kaee8lihpg/Samples.xlsx?dl=0
I haven't done anything with these yet. The structure is a little different than my description, but close. On Sample1, other than the title which is easily handled, every two rows contain the values which should be a single row. On Sample2, there are 4 rows of column headings and then 4 rows for each record.
Unfortunately I can't simply look up the table from the web because I can't make the authentication work. Plus, I don't even know if it is written properly as a table for PowerQuery to recognize it.
You can use this function: https://github.com/ImkeF/M/blob/master/Library/Table.PivotSingleColumn.pq
Just make sure that you get rid of the excess column name-rows. Your table must only contain values that shall go into the new columns.
In the 1st parameter you reference your table and in the 2nd you enter the number of new columns (2 or 4 according to your examples).
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
Thank you! You truly are a genius. I haven't had time to download and apply it yet, but just looking at the code I can tell that it is exactly what I need.
Do you have a blog site or anything or do you spend all your "spare" time answering questions and helping people here?
You just made my life much easier. Again, thank you!
Thank you @alwweb 🙂
I'm blogging here: www.TheBIccountant.com
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 |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
118 | |
101 | |
71 | |
61 |