Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi All,
I pulled out some data from a PDF and as expected not all data are well presented. My issues is that I have sometimes blank columns and all the data moved to the right. I need to get some data shifted to the left, I have tried unpivot but did not work for me
Here is the screenshot
let
Source = Pdf.Tables(File.Contents("C:\XXXX\XXXX\XXXX\Storage 12.12.22 - 289775.pdf"), [Implementation="1.3"]),
#"Lignes filtrées" = Table.SelectRows(Source, each ([Kind] = "Page")),
#"Data développé" = Table.ExpandTableColumn(#"Lignes filtrées", "Data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11"}, {"Data.Column1", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5", "Data.Column6", "Data.Column7", "Data.Column8", "Data.Column9", "Data.Column10", "Data.Column11"}),
#"Colonnes supprimées" = Table.RemoveColumns(#"Data développé",{"Id", "Name", "Kind", "Data.Column1"}),
#"Lignes filtrées1" = Table.SelectRows(#"Colonnes supprimées", each ([Data.Column2] <> null and [Data.Column2] <> "Card Payments :" and [Data.Column2] <> "M3 7BB" and [Data.Column2] <> "Part No" and [Data.Column2] <> "SALFORD")),
#"Colonnes supprimées2" = Table.RemoveColumns(#"Lignes filtrées1",{"Data.Column4", "Data.Column5"})
in
#"Colonnes supprimées2"Here is my M code
Solved! Go to Solution.
Hi @Einomi ,
Suppose we have:
You may consider creating three new conditional columns. like this:
= if [Data.Column6] = null then [Data.Column7] else [Data.Column6]= if [Data.Column6] = null then [Data.Column8] else [Data.Column7]= if [Data.Column6] = null then null else [Data.Column8]
Then remove and rename the columns.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYmOlWJ1oJQQnFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data.Column6 = _t, Data.Column7 = _t, Data.Column8 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Data.Column6", Int64.Type}, {"Data.Column7", Int64.Type}, {"Data.Column8", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Data.Column6] = null
then [Data.Column7] else [Data.Column6]),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if [Data.Column6] = null
then [Data.Column8] else [Data.Column7]),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each if [Data.Column6] = null
then null else [Data.Column8]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Data.Column6", "Data.Column7", "Data.Column8"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Data.Column6"}, {"Custom.1", "Data.Column7"}, {"Custom.2", "Data.Column8"}})
in
#"Renamed Columns"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @Einomi ,
Suppose we have:
You may consider creating three new conditional columns. like this:
= if [Data.Column6] = null then [Data.Column7] else [Data.Column6]= if [Data.Column6] = null then [Data.Column8] else [Data.Column7]= if [Data.Column6] = null then null else [Data.Column8]
Then remove and rename the columns.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYmOlWJ1oJQQnFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data.Column6 = _t, Data.Column7 = _t, Data.Column8 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Data.Column6", Int64.Type}, {"Data.Column7", Int64.Type}, {"Data.Column8", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Data.Column6] = null
then [Data.Column7] else [Data.Column6]),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if [Data.Column6] = null
then [Data.Column8] else [Data.Column7]),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each if [Data.Column6] = null
then null else [Data.Column8]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Data.Column6", "Data.Column7", "Data.Column8"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Data.Column6"}, {"Custom.1", "Data.Column7"}, {"Custom.2", "Data.Column8"}})
in
#"Renamed Columns"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Thanks Gao 🙂
@Anonymousit works good. I had to shift 6 or 7 columns but the logic works 🙂
any help 🙂
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 3 |