Forum Discussion
power query - data cleaning and analysis
- May 15, 2021
i am talking about the fixed width feature as shown belowSergeiBaklan
You may query the column, slit text by position, change types, return table into sheet and add totals.
Please check in attached.
Greetings,
I am regular watching your vlog related excel, and now i need your help to clean a complex type of data extracted from my company system which i need to clean and provide them in simple form to create some insight from that.
1st sheet as sample extracted
i have given two sets of data as sample, whereas in my co file having 25860 rows of data for almost 1185-person
2nd sheets need to be normalized
it would be much appreciated if you could help me out
Thanks
Naushad Ali
1st table
| Extracted messy data | 11/11/2012 | |||||||||||||
| ID | 818181 | role | data practioner | |||||||||||
| school | ||||||||||||||
| grade | 12 | |||||||||||||
| try | ||||||||||||||
| fry | ||||||||||||||
| sum | ||||||||||||||
| code | title | |||||||||||||
| 121212 | jsr | |||||||||||||
| ________________________________________________________________________________________________________ | ||||||||||||||
| ID | 919191 | role | Sr Data player | |||||||||||
| school | ||||||||||||||
| grade | 14 | |||||||||||||
| try | ||||||||||||||
| fry | ||||||||||||||
| sum | ||||||||||||||
| code | title | |||||||||||||
| 121212 | jsr | |||||||||||||
| 212121 | kel | |||||||||||||
| ________________________________________________________________________________________________________ | ||||||||||||||
2nd table - needed
| ID | Role | grade | code | title |
| 818181 | data practioner | 12 | 121212 | jsr |
| 919191 | Sr Data player | 14 | 121212 | jsr |
| 212121 | kel |
- SergeiBaklanOct 22, 2024Diamond Contributor
forgot csv
- noushad1ali2000Oct 22, 2024Copper Contributor
SergeiBaklan Appreciated, it is really same what i am looking for
Thanks a lot
could you please elaborate little more or could you please suggest some video related to this topic
Thanks once again ..
- SergeiBaklanOct 23, 2024Diamond Contributor
First we remove the row with date of extraction
and split the rest on the tables having blocks of 15 rows each
Each table in this list is transformed by function, results are combined.
What function do is first renames columns with needed information in the table
, remove all other columns, replace spaces and empty strings on null. Next transform table to columns, in each column remove nulls and combine table back from such columns.
- SergeiBaklanOct 22, 2024Diamond Contributor
With some assumptions regarding the logic in source data, and keeping the source in csv file, main query could be
let BlockSize = 15, Source = Csv.Document(File.Contents("C:\Test\Source.csv"),[Delimiter=",", Columns=15, Encoding=65001, QuoteStyle=QuoteStyle.None]), RemoveDate = Table.Skip(Source,1), SplitSource = Table.Split( RemoveDate, BlockSize), Custom1 = Table.Combine( List.Transform( SplitSource, (t) => fnTransformID(t) ) ) in Custom1which calls the function
(tbl as table) => let RenameColumns = Table.RenameColumns( tbl, { {"Column2", "Code"} , {"Column3", "Grade"} , {"Column5", "ID"} , {"Column9", "Title"} , {"Column13", "Role"} }), names = {"ID", "Role", "Grade", "Code", "Title"}, SelectColumns = Table.SelectColumns(RenameColumns,names), ReplaceSpace = Table.ReplaceValue(SelectColumns," ",null,Replacer.ReplaceValue,names), ReplaceEmpty = Table.ReplaceValue(ReplaceSpace,"",null,Replacer.ReplaceValue,names), ReplaceRoleWord = Table.ReplaceValue(ReplaceEmpty,"role",null,Replacer.ReplaceValue,{"Title"}), ToColumns = Table.ToColumns( ReplaceRoleWord ), RemoveNulls = List.Transform( ToColumns, (q) => List.RemoveNulls(q)), GetTable = Table.FromColumns( RemoveNulls, names ) in GetTableResult is
Please check attached file