Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3276

Adjust information based on another row

$
0
0

Hi everyone,

 

I am stuck on a problem for a while and can't find the solution to this in other posts. I have made a query which is working properly but I have to change one more thing in the output. Because of the size of the output, it is not really an option to adjust everything manually. In essence this is the problem:

 

In column A (Code), I see for every row a code (mostly unique codes, but sometimes they match with other rows). In column B (type), I see a certain letter. (For calculations in other columns, column A has to be sorted (A-Z).

 

The thing I would like to have now: If two codes are the same, and one of the Types is a "D", then all Types with this code should be a "D". So as example; In row 6 (with code 4444) the "E" should become a "D". Furthermore, in row 8, 9, 10, the "C" should both become a "D". For the two rows at the bottom, the Bs should not be changed.

 

 

Code

Type

1111

A

2222

B

3333

C

4444

D

4444

E

5555

B

6666

C

6666

C

6666

C

6666

D

7777

B

7777

B

 

 

I tried the following: If Previous([Code])=[Code] And Previous([Type])="D" Then "D" Else [Type]

 

However, there is apparently no Next function, so it only works for one direction. Furthermore, sometimes multiple rows have to be changed into a D (for example row 8, 9, 10).

 

I am looking for a way to do this. It does not really matter whether I have to adjust the formula for variable "Type" or to create a new variable. (Maybe important to mention, I have simplified the case in this post, the codes consist normally out of 10 random numbers which I don't know beforehand and do not have a relation to the Type). If I forgot any crucial information or if I was unclear, please let me know.

 

Thanks a lot in advance for your help!


Viewing all articles
Browse latest Browse all 3276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>