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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors