Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Rune_
Frequent Visitor

Replace date if x value with other column date else keep date

I have a column (Lovet leveringsdato) where if no date has been input the default date is 01.01.1753. 

I want to replace all values containing 01.01.1753 with date from column (Levert dato), if other date then keep the date. 

 

I have tried with these formulas:

 

= Table.ReplaceValue(#"Egendefinert lagt til",each [Lovet leveringsdato], each if Date.From([Lovet Leveringsdato]) = #date(1753, 1, 1) then [Levert Dato] else [Lovet leveringsdato],Replacer.ReplaceValue,{"Lovet leveringsdato"})

 

and

 

= Table.ReplaceValue(#"Egendefinert lagt til",each Date.From([Lovet leveringsdato]), each if Date.From([Lovet Leveringsdato]) = #date(1753, 1, 1) then [Levert Dato] else [Lovet leveringsdato],Replacer.ReplaceValue,{"Lovet leveringsdato"})

 

Here are the columns

 

Rune__1-1596184349529.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Rune_ Why don't you try to add a conditional column like this.

 

 

levert dato.PNG

 

Hope this helps.

 

Appreciate with kudos.

Please mark as a solution if this solves the problem.

 

Thanks

View solution in original post

4 REPLIES 4
Fowmy
Super User
Super User

@Rune_ 

Right  click on 1st column,
Select Replace Value, ( Value to find =  "1.1.1753" and Replace with "1") click ok,
Select the Replace Step in power query steps pane and modify the code in the middle where it shows "1" to each [Levert dato]

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Rune_
Frequent Visitor

@Fowmy 

 

This did not work. Probably because it is a date column. 

 

My formula work when I tired it on text column. I guess yours will also. 

@Rune_ 

You could try

Replacer.ReplaceValue if its Replacer.ReplaceText

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Hi @Rune_ Why don't you try to add a conditional column like this.

 

 

levert dato.PNG

 

Hope this helps.

 

Appreciate with kudos.

Please mark as a solution if this solves the problem.

 

Thanks

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors