cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Applicable88
Impactful Individual
Impactful Individual

Replace every row with the first row value

Hello,

 

I'm loading multiple csv files into PowerQuery. 

These are unformatted csv files. Somwhere in the first row is a date field. Before I can delete the first few rows to get to my

actually promoted header, I need to extract that very date value into a extra column. It works well so far with "Add Conditional Column". The problem are the other values below that row, which are different numbers or strings:

 

Custom
11.02.2022
 
sdfdf
dfd
df
dffd
dfd

 

Now as a sample table, I need to put that date into every row. But "fill down" doesn't work because it only can work with empty or null  cells. If I transform that column into date dateype I get this:

Custom
11.02.2022
Null
Error
Error
Error
Error
Error

 

Fill down also doesn't work with this. How can I write "first value in first row" into every cell below?

Thank you very much in advance. 

Best. 

2 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @Applicable88 ,

 

Create a new custom column, and enter this as the calculation:

previousStepName{0}[Custom]

 

This will fill the column with the first value in the [Custom] column.

 

Like this:

BA_Pete_0-1643724069940.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

AlexisOlson
Super User
Super User

If you prefer, you could transform the existing column instead of creating a new one. Try a conversion to date returning null for values that don't work and then fill down.

= Table.FillDown(
      Table.TransformColumns(
          #"Previous Step Name Goes Here",
          {{"Custom", each try Date.FromText(_) otherwise null, type date}}
      ),
      {"Custom"}
  )

 

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

If you prefer, you could transform the existing column instead of creating a new one. Try a conversion to date returning null for values that don't work and then fill down.

= Table.FillDown(
      Table.TransformColumns(
          #"Previous Step Name Goes Here",
          {{"Custom", each try Date.FromText(_) otherwise null, type date}}
      ),
      {"Custom"}
  )

 

BA_Pete
Super User
Super User

Hi @Applicable88 ,

 

Create a new custom column, and enter this as the calculation:

previousStepName{0}[Custom]

 

This will fill the column with the first value in the [Custom] column.

 

Like this:

BA_Pete_0-1643724069940.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hello Pete,

 

it seems like your answer is the solution to my problem.

But unfortunate it doesn't work in my case. 

I need a new column where every row takes the value from first row column month.

Could you pls have a look at it and advice?

Franz_Osaka__0-1669868715014.png

 

 

 

Hi @Franz_Osaka_ ,

 

For your scenario, it should just be:

previousStepName{0}[Month]

 

Where 'previousStepName' is the name of whatever Power Query step this linecomes after in the process order.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Kudoed Authors