Forum Discussion

Frixel's avatar
Frixel
Post Prodigy
1 year ago
Solved

How get data from row above

 

hello,

 

How do I get the data from the line above into the 'article number' column?

 

 

 

like this

 

 

 

  • Frixel Try using

    In the Power Query Editor, go to the "Add Column" tab.
    Click on "Custom Column".
    In the "Custom Column" dialog, you can use the following formula to shift the data from the line above into the 'article number' column:
    m
    = if Text.StartsWith([ColumnName], "Artikelnummer") then null else try #"Previous Row"[ColumnName] otherwise null


    Replace ColumnName with the actual name of your column.

    Fill Down the Values:

    After creating the custom column, you need to fill down the values to propagate the 'article number' to the rows below.
    Select the new custom column.
    Go to the "Transform" tab.
    Click on "Fill" > "Down".

5 Replies

  • Frixel Try using

    In the Power Query Editor, go to the "Add Column" tab.
    Click on "Custom Column".
    In the "Custom Column" dialog, you can use the following formula to shift the data from the line above into the 'article number' column:
    m
    = if Text.StartsWith([ColumnName], "Artikelnummer") then null else try #"Previous Row"[ColumnName] otherwise null


    Replace ColumnName with the actual name of your column.

    Fill Down the Values:

    After creating the custom column, you need to fill down the values to propagate the 'article number' to the rows below.
    Select the new custom column.
    Go to the "Transform" tab.
    Click on "Fill" > "Down".

    • Frixel's avatar
      Frixel
      Post Prodigy

      Thanks @bhanu_gautam 

       

      What do you mean with the 'm' before the formule?

      I get this error

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from bhanu_gautam, please allow me to provide another insight.

    Hi Frixel ,

     

    Select the 'Artikelnummer' column, in the 'Transform' tab, select 'Fill', then select 'Down'

     

    The final result is as follows. Hopefully it will meet your needs.

     

    Please see the attached pbix for reference.

     

    Best Regards,
    Dengliang Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Frixel's avatar
      Frixel
      Post Prodigy

      Thanks Anonymous 

       

      The reason it didn't work for me was because there were empty lines. I filled the empty lines with 'null' and then the Fill down worked

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Frixel ,

         

        It looks like your problem has been solved, please mark the helpful reply and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster .
        Thank you very much for your kind cooperation!

         

        Best Regards,
        Dengliang Li