M language - Comparing two consecutive rows in the same colum

Guinaba

Board Regular
Joined
Sep 19, 2018
Messages
233
Office Version
  1. 2016
Platform
  1. Windows
Hi experts,

I need to create in Power Query the column SKU Logic:

Using the following logic: if Week# col. has the lowest value and Code col. value (r) = value (r+1) then 0 else 1. Any help much appreciate it.


Week#CodeSKU Logic
11230
21231
31231
41231
51231
61231
71231
12340
22341
32341
42341
52341
62341
72341
15670
25671
35671
45671
55671
65671
75671
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi @Matt Allington ,

Thanks a lot! That's a great technique!! Definitely I'll adopt it from now on! May I ask you one last question, considering that I have the col Logic (0,1) now.
Would you know how I can do one more calculation step 4

step 1 - Sort Col A - Asc - Done
step 2 - Sort Col B - Asc - Done
step 3 - Create col. Logic - Done
step 4 - Create col. Coverage using the logic:
=IF Col.Logic=0 then (D1+E1+F1)-G1 else (I1+E2+F2)-G2)

The problem is when the Logic=1 (next row), then I have to replace D2 for I1 and do the calculation for the next rows having Logic=1, I have added the table below illustrating the scenario, sorry if it confusing.

Week#CodeSKU-DESCDEFGSKU LogicCoverageFirstWk (Col.I)CoverageNextWeekCoverageWeeks
1123ProdA3016014 (I1)14
2123ProdAD221=(14+E2+F2)-G212
3123ProdA517
4123ProdA83112
5123ProdA319
6123ProdA217
7123ProdA5418
1234ProdB2520055
2234ProdB411
3234ProdB61-5
4234ProdB1081-3
5234ProdB51-8
6234ProdB31-11
7234ProdB261-15
1567ProdC401602424
2567ProdC2122
3567ProdC5117
4567ProdC13115
5567ProdC3112
6567ProdC2110
7567ProdC84114

I've tried using the following formula:

if [Logic]=1 then
[CoverageFirstWeek]+[E]+[F]-[G] else null

But not sure how to get the value from the previous row, do I have to use to index col tech. again to get a record from one row above?

Kind Regards,
Gilly
 
Upvote 0
Myabe I should do this step using excel or VBA (offset)
 
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top