Removal of consecutive Yes

Sunil M P

New Member
Joined
Dec 31, 2014
Messages
15
QUERY : There should not be 2 consecutive "YES". If so, then the 2nd "YES" should be replaced with "NO".:confused: Please find below the sample Input data and desired Output, to be achieved using POWER QUERY.[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]INPUT[/TD]
[TD]OUTPUT[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]YES[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]YES[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]YES[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]YES[/TD]
[/TR]
[TR]
[TD]NO[/TD]
[TD]NO[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]YES[/TD]
[/TR]
[TR]
[TD]YES[/TD]
[TD]NO[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi :-)
Try this code:

let
Source = Excel.CurrentWorkbook(){[Name="Tabela1"]}[Content],
AddedIndex = Table.AddIndexColumn(Source, "Indeks", 0, 1),
AddCol1 = Table.AddColumn(AddedIndex, "Custom", each if [INPUT] = "NO" then [Indeks] else null),
FillDown1 = Table.FillDown(AddCol1,{"Custom"}),
RepVal = Table.ReplaceValue(FillDown1,null,1,Replacer.ReplaceValue,{"Custom"}),
AddCol2 = Table.AddColumn(RepVal, "Custom.1", each if [INPUT] = "YES" then [Indeks] - [Custom] else 1),
AddCol3 = Table.AddColumn(AddCol2, "Custom.2", each if Number.IsEven([Custom.1]) then "NO" else [INPUT]),
RemOtCol = Table.SelectColumns(AddCol3,{"Custom.2"}),
ChNameCol = Table.RenameColumns(RemOtCol,{{"Custom.2", "Output"}})
in
ChNameCol
 
Upvote 0

Forum statistics

Threads
1,224,061
Messages
6,176,152
Members
452,707
Latest member
laplajewelry

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