Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Convert Line break values to Row without disturbing other columns value

Hi Superuser,

 

Could you please help on dealing line break values without disturbing other columns values

Columns which has line break value are as below

TRANSACTIONOPPORTUNITY  TYPEOPPORTUNITY  #APPROVAL STATUS

 

Sample Data 

 

Reul

  • MFelix's avatar
    MFelix
    6 years ago

    Hi Anonymous ,

     

    If you go to the step where the error is changed just click the cog weel and instead of null write the text you need.

     

     

11 Replies

  • The information you have provided is not making the problem clear to me. Can you please explain with an example.

    Appreciate your Kudos.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak 

       

      Please refer below link where i have raised same query earlier and Ashish Mathur has solved most of it but the sum of Rent in that refence file is not matching with each

       

      If you still have a query please let me know 

       

      Reference thread 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi MFelix 

       

      Please refer below link where i have raised same query earlier and Ashish Mathur has solved most of it but the sum of Rent in that refence file is not matching with each

       

      If you still have a query please let me know 

       

      Reference Thread 

      • MFelix's avatar
        MFelix
        Super User

        Hi Anonymous ,

         

        Based on the video below you can achieve the expected result

         

        Basically or your setup you need to create 4 additional columns with the following code:

        Transation break column
        Text.Split([TRANSACTION], "#(lf)")
        
        Opportunity type break column
        Text.Split([OPPORTUNITY  TYPE], "#(lf)")
        
        Opportunity break column
        try Text.Split([#"OPPORTUNITY  #"], "#(lf)") otherwise
        Text.ToList(Number.ToText([#"OPPORTUNITY  #"]))
        
        Approval status break
        Text.Split([APPROVAL STATUS], "#(lf)")
        

         

        This will create 4 tables with  list for each line with line breaks. The Opportunity is a little different since when theres is only one value you are converting numbers and it returns errors

         

        Now create a column tha concatenates all the other columns:

        Table.FromColumns({[Transaction_Break],[Opportunity_Type_break],[Opprtunite_break],[Approval_Status_Break]})

        Finally just expand this table rows and delete the 8 previous columns.

         

        Check the code below:

        let
            Source = Excel.Workbook(File.Contents("C:\Line Break.xlsx"), null, true),
            Data_Sheet = Source{[Item="Data",Kind="Sheet"]}[Data],
            #"Promoted Headers" = Table.PromoteHeaders(Data_Sheet, [PromoteAllScalars=true]),
            #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Transaction_Break", each Text.Split([TRANSACTION], "#(lf)")),
            #"Added Custom1" = Table.AddColumn(#"Added Custom", "Opportunity_Type_break", each Text.Split([OPPORTUNITY  TYPE], "#(lf)"),type text),
            #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Opprtunite_break", each try Text.Split([#"OPPORTUNITY  #"], "#(lf)") otherwise
        
        Text.ToList(Number.ToText([#"OPPORTUNITY  #"]))),
            #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Approval_Status_Break", each Text.Split([APPROVAL STATUS], "#(lf)")),
            #"Added Custom4" = Table.AddColumn(#"Added Custom3", "Table_from_Columns", each Table.FromColumns({[Transaction_Break],[Opportunity_Type_break],[Opprtunite_break],[Approval_Status_Break]})),
            #"Expanded Table_from_Columns" = Table.ExpandTableColumn(#"Added Custom4", "Table_from_Columns", {"Column1", "Column2", "Column3", "Column4"}, {"Table_from_Columns.Column1", "Table_from_Columns.Column2", "Table_from_Columns.Column3", "Table_from_Columns.Column4"})
        in
            #"Expanded Table_from_Columns"

         

        I have made a filter of all rows with line breaks and result appears correct.