Forum Discussion

emckula's avatar
emckula
New Member
5 years ago
Solved

Conditional Merge of columns based on PDF extraction

Hello,

 

I'm currently working on a project to extract, transform and present data mainly from pdf files. Sometimes the extractios for a new version of the pdf separates the value of one column into two. This is not entirely recurrent, so I want to create the steps to validate it and in case if happens, merge those 2 columns and delete the second one of each instance (the one with all the null values and only a value of 3 on row 15), and if it's not happening then keep the rows as they are.

 

If you check the values on columns 10 and 11, you will see that it's separating the value of row 15 which should be 1.3 on column 10. 

As I'm appending 3 different pages of the pdf, I get an inconsistent number of columns on the append result.

 

Any help would be appreciated.

 

best Regard,

 

Eduardo M.

  • Hello emckula 

     

    you need a trigger to identify when a table has to be adapted. Once you have the trigger, then you need to adapt the table (Create new column wher you combine the data, and afterwards rename all columns accordingly.

    Your code could look like something like this

    if Table.ColumnsCount(PreviousStep)=10 then 
     let 
        AddColumn = Table.AddColumns(PreviousStep, "new", each [Column10] & [Column11]), 
        Rename = Table.RenameColumns(AddColumn............
     in
        Rename
      else 
         PreviousStep

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy

     

1 Reply

  • Jimmy801's avatar
    Jimmy801
    Community Champion

    Hello emckula 

     

    you need a trigger to identify when a table has to be adapted. Once you have the trigger, then you need to adapt the table (Create new column wher you combine the data, and afterwards rename all columns accordingly.

    Your code could look like something like this

    if Table.ColumnsCount(PreviousStep)=10 then 
     let 
        AddColumn = Table.AddColumns(PreviousStep, "new", each [Column10] & [Column11]), 
        Rename = Table.RenameColumns(AddColumn............
     in
        Rename
      else 
         PreviousStep

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy