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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vlahari06
Frequent Visitor

Replace values of a column based on a condition on another column

Hi, I have a table like below, 

 

Dateorder numberChocolate numberlength of the barExpected lengthproduct code
10/2/20231188101
11/2/20231288101
12/2/20231388101
13/2/20231428101
14/2/20231488101
15/2/20231588101
16/2/20231688101
17/2/2023197168101
18/2/20232981616102
19/2/20232991616102
20/2/202321001616102

 

Here, each order produces multiple chocolates. There are duplicate chocolate numbers because it was not produced as expected and considered scrap. So they produced the same chocolate bar again the next day. The manufacturing process is flexible, so 96 chocolate bars are produced in January for order number 2 and starting from 97 they are being produced in february.  

 

If you closely check the chocolate number 97, the order number, expected length and product code still stayed the same as the previous row. 

 

Now I would like to update the values of 3 columns - order number, product code and expected length for the chocolate number - 97.

I would like to do:
compare chocolate number for this row and previous row - if(( the number is same) or (next consequtive number)) then Do Nothing
else compare chocolate number for this row and next row - if(( the number is same) or (next consequtive number)) then replace the values of product code, order number and expected length for that row

 

Note: The assumption here is the table is ordered by Date.

 

I hope the question makes sense. Looking forward for some help.

Thank you in advance 🙂

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @vlahari06 ,

 

What value do you want to replace the original value with, and please specify what kind of value is used for the replacement?

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Whenever the order number changes the first row of the changed order number details should be replaced by it's consequtive row (order number, product number, expected length).

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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