Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Join two columns and add a consecutive number at the end, but only when there's a certain text in one of the columns

$
0
0

I have three columns (cross_type, parent_cross_ID, and transplant_ID). I want to join the cross_type and parent_cross_ID columns, but I want to add a consecutive number at the end (behind either an underscore or a period). I have five crosstypes and am only keeping one type that would require this so I want it to generate a specific transplant_ID only when the cross_type column is one of the five crosstypes.

Transplant IDcrosstypeparent_cross_ID
FF_31_1FF31
FF_31_2FF31
FA34
FF_31_3FF31
FC23
FF_40_4FF40
FF_40_5FF40
CF50
AF55

Hopefully, that helps to visualize what I mean. When the cross is "FF", I want to generate a unique transplant ID from the crosstype column and the parent_cross_ID with a unique, but consecutive number at the end.

When there's any other crosstype, it doesn't have to generate a unique transplant_ID because I don't need anything beyond their germination location for those four crosstypes. The FF crosses are the only ones that need a unique transplant ID.

I've tried using some combinations of "join", "sequence" and "if", but it keeps giving me back errors so I must be doing something wrong.

Thank you in advance!


Viewing all articles
Browse latest Browse all 9782

Trending Articles