Hello,
I'm writing a LAMDA function that considers three identifying pieces of information, i.e. subject_ID (column A), specimen_ID (column B), and scan_ID (column C) in my "Data" sheet, to determine drug_level (from column H of "Input" sheet). The Input sheet contains the same three columns A, B, and C as the Data sheet.
Due to various reasons, not all three pieces of information are listed for all samples, and each subject_ID may have more than one sample. So scan_ID and specimen_ID both refer to a unique sample, but subject_ID may refer to multiple scan-IDs and/or specimen_IDs.
Now, ideally I want to check all three (maximum) pieces of information at the beginning of the calculation, in order to get the drug_level. Then if I get an error value, then drop one of the three criteria at a time (i.e. check 2 of the three), and then if that doesn't work, use only one of the three, and if nothing comes up by the end of the function, get a message like "No data found!". And for all steps I want to include a check to ensure the output would be unique (except for subject_ID alone test), and if not I would want to get a message like "double check input data for accuracy!". And for subject_ID alone test, if there are more than one result, I could get a message like "more than one sample found".
I can of course do this myself through multiple nested IFs, but I was thinking there should likely be a more elegant/advanced way of doing this which would be shorter/neater?
If so, I would appreciate any directions!
I'm writing a LAMDA function that considers three identifying pieces of information, i.e. subject_ID (column A), specimen_ID (column B), and scan_ID (column C) in my "Data" sheet, to determine drug_level (from column H of "Input" sheet). The Input sheet contains the same three columns A, B, and C as the Data sheet.
Due to various reasons, not all three pieces of information are listed for all samples, and each subject_ID may have more than one sample. So scan_ID and specimen_ID both refer to a unique sample, but subject_ID may refer to multiple scan-IDs and/or specimen_IDs.
Now, ideally I want to check all three (maximum) pieces of information at the beginning of the calculation, in order to get the drug_level. Then if I get an error value, then drop one of the three criteria at a time (i.e. check 2 of the three), and then if that doesn't work, use only one of the three, and if nothing comes up by the end of the function, get a message like "No data found!". And for all steps I want to include a check to ensure the output would be unique (except for subject_ID alone test), and if not I would want to get a message like "double check input data for accuracy!". And for subject_ID alone test, if there are more than one result, I could get a message like "more than one sample found".
I can of course do this myself through multiple nested IFs, but I was thinking there should likely be a more elegant/advanced way of doing this which would be shorter/neater?
If so, I would appreciate any directions!
Last edited: