Forum Discussion

cdfjdk1's avatar
cdfjdk1
Copper Contributor
Oct 17, 2024

Power Query copy value to first row only

I am trying to copy only the value in the first row in one column to the first row in a new column, else null for all other rows. Help gratefully received.

  • cdfjdk1 I guess you want to add a conditional column with the following code:

    = if [Index] = 0 then [Column A] else null

     

    And in case you then want to fill the entire column with that number, right-click on the column header, Fill, Down.

     

    Or this might also work for you. Add a custom column with the following code to fill the entire column with the first number of Column A. No need for an Index column then.

    =Source[Column A]{0}

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    cdfjdk1 I guess you want to add a conditional column with the following code:

    = if [Index] = 0 then [Column A] else null

     

    And in case you then want to fill the entire column with that number, right-click on the column header, Fill, Down.

     

    Or this might also work for you. Add a custom column with the following code to fill the entire column with the first number of Column A. No need for an Index column then.

    =Source[Column A]{0}

    • cdfjdk1's avatar
      cdfjdk1
      Copper Contributor
      Ah! Thank you
      = if [Index] = 0 then [Column A] else null
      is so simple I'm embarrassed I didn't think of that myself!
      • Riny_van_Eekelen's avatar
        Riny_van_Eekelen
        Platinum Contributor

        cdfjdk1 That happens sometimes. No worries. By the way. I added another solution after you may have looked at my initial response. An all-in-one solution.

Resources