Remove Rows based on condition

tejapowerbi

New Member
Joined
Nov 30, 2018
Messages
19
Hello,

I want to remove receipts no which have opposite values (Y vs N,1 vs -1 etc.).if each receipt's row has opposite row. I.e. if also will be row 500.2 (with any content) - receipt 500 will not be removed.

Receipt NoIndicatorCountRateRegion ID
500N110011
600N120012
601N130013
500.1Y-1-100-11
603N140014
Final Result
Receipt NoIndicatorCountRateRegion IDComments
500N110011Remove
500.1Y-1-100-11Remove
600N120012Keep
601.1N130013Keep
603.2N140014Keep

<tbody>
</tbody>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I think you need to clarify your question please. I know it's not easy posting in a foreign language but your initial sentences makes no sense, try breaking them into smaller pieces perhaps? I don't understand how the Final Result can be generated when some of the data does not exist in the original source. What are the rules to create 601.1 and 603.2 for example. Can you post the code you have tried so far?
Good luck solving your problem
Peter
 
Upvote 0
Hi Peter,
First formula should check Invoice no with .1 Example 100.1 and after that in the same row it should also find related rows Example 100.if those condition match then remove those 2 rows.
Example
Receipt No with .1 Example 100.1 then find 100.
please let me know if you need more information.
 
Upvote 0
<Peter>What are the rules to create 601.1 and 603.2 for example. Can you post the code you have tried so far?
Rule is if receipt no is without .1 or any unique no i want to keep it .
Please see below code ,
Solutons 1:
let
Source = Excel.CurrentWorkbook(){[Name="Table"]}[Content],
key = Table.AddColumn(Source, "key", each Text.BeforeDelimiter(Text.From([Receipt No], "ru-RU"), "."), type text),
transform = Table.TransformColumns(key, {"Indicator", each Record.FieldOrDefault([N = -1, Y = 1], _, _)}),
group = Table.Group(transform, {"key"}, {"a", each List.Sum(List.Combine({[Indicator],[Count],[Rate],[#"Region ID"]})), type number}),
list = Table.SelectRows(group, each [a] = 0)[key],
filter = Table.SelectRows(key, each not List.Contains(list, [key])),
final = Table.RemoveColumns(filter,{"key"})
in
final
Above query gets an error “Region id”column not found ,I have removed region_id column and scripts works fine but did not give me correct result.
Solutions:2
Below formula works for me but I have a duplicate data in my dataset and I am getting “A table of multiple values was supplied where a single value was expceted error” I am not sure how to fix?
Check =
IF (
LOOKUPVALUE (
'Raw Data'[No],
'Raw Data'[Count], 'Raw Data'[Count] * -1,
'Raw Data'[Avg], 'Raw Data'[Avg] * -1,
'Raw Data'[Curr], 'Raw Data'[Curr] * -1
)
<> BLANK (),
"A",
"B"
)
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,181
Members
448,871
Latest member
hengshankouniuniu

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