I have a dataset and I have to A if B is there in the same account and if B alone is there then I have to keep the B
Example:
Account | value |
123 | A |
123 | B |
123 | A |
124 | A |
124 | A |
125 | B |
125 | B |
121 | B |
Output:
Account | value |
123 | A |
123 | A |
124 | A |
124 | A |
125 | B |
125 | B |
121 | B |
So basically, in account 123, with A the B was also coming so I have to remove it but with account 125 and 121 only B was there so kept it.
@Sshasnk
Maybe not the best way. 😂
@RobertOdera Your solution is the closest one but still not right. I is failing if in the same account, it has more than one B in account 123
Account | value |
123 | A |
123 | B |
123 | A |
124 | A |
124 | A |
125 | B |
125 | B |
121 | B |
123 | B |
Hi, @Sshasnk
So, a couple things, please:
1. Improve your explanation of your desired result
2. Improve the comprehensiveness of your input and desired output sample
It looks like those goal posts are shifting.
Given the above, we will help you get there, no problem - cheers!
@RobertOdera As I mentioned in my question
1. If I have A and B in the same account replace all the B's and keep all the A's
2. If only A is there keep all of them
3. If only B is there keep all of them.
Now in your solution if I have more than one B, In this case rest of B's are still there
😎
@RobertOdera Yes, exclude B's