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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Qotsa
Helper V
Helper V

Replace values in one column based on date range from another

Hi,

 

Looking to replace all values 'X1' in column A with values 'X2' using M language. Can't duplicate column A.

 

Condition is that only replace the values for date range between 01/01/20 to 06/06/20 using column 'Date' in same table.

 

1 ACCEPTED SOLUTION
ziying35
Impactful Individual
Impactful Individual

Hi, @Qotsa 

try the code below:

 

= Table.ReplaceValue(
          YouPreviousStepName, 
          each [Date]>=#date(2020, 01, 01) and  [Date]<=#date(2020, 06, 06), 
          each [column A]="X1", 
          (x,y,z)=>if y and z then "X2" else x, 
          {"column A"} 
     )

 

View solution in original post

2 REPLIES 2
ziying35
Impactful Individual
Impactful Individual

Hi, @Qotsa 

try the code below:

 

= Table.ReplaceValue(
          YouPreviousStepName, 
          each [Date]>=#date(2020, 01, 01) and  [Date]<=#date(2020, 06, 06), 
          each [column A]="X1", 
          (x,y,z)=>if y and z then "X2" else x, 
          {"column A"} 
     )

 

@ziying35 

Thank you for this.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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