The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 For and if statment for sorting condition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

zknauss

USA
72 Posts

Posted - 09/27/2022 :  11:19:21 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to write a for/if statement to label my data sets based on a condition. I have most of it working except for the very last line which defines whether to label the data as a "D" or "B". what I need it do is match the following rules:

1. if xx<5 the resulting value should be "D"
or
2. if bb==0 the resulting value should be "D"
or
3. if zz=="B" && bb<aa[40] the resulting value should be "D"
4. if the above are not true the resulting value should be "B"

I need this to be integratable with the first section of the working part. I've listed three versions of this script I've tried without any luck. I just get a constant output of "D" when I know I should be getting A,B,C in my data. Version 1 was my latest attemp and I tried flipping it around and baseing the calculation off "B" but still didn't work.

Part working:
for (int i = 2; i <= wks.ncols; i++ ){
range aa = [NCONFreReg]"Frequency_T1"!$(i);
range bb = [NCONFreReg]"Frequency_T2"!$(i);
range xx = [NCONT2Peak]"Peak Counts"!$(i);
range zz = [FreqSortNCON]"FRQSorting_N_CON"!$(i);
wcol(i)[2]$ = if(bb[2]>=aa[40]&&xx>5,"A",if(bb[2]<=aa[41]&&xx>5,"C",

Not working:

Version 1
if(xx>5&&bb[2]<aa[40]&&bb[2]>aa[41]&&zz[1]=="B","B","D")$)$)$; }

Version 2
if(bb[2]==0||xx<5 ||(zz[1]=="D"&&bb[2]<aa[40]),"D","B")$)$)$; }

Version 3
if(bb[2]==0||xx<5 ||if(zz[1]=="D"&&bb[2]<aa[40]),"D","B")$)$)$; }


ZTK

Edited by - zknauss on 09/27/2022 11:20:30 AM

zknauss

USA
72 Posts

Posted - 09/27/2022 :  1:22:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Figured it out the issue was I needed to add another resultant to the formula:

if(bb[2]==0||xx<=5 ||if(zz[1]=="D"&&bb[2]<(aa[40]),"D"),"D","B")$)$)$; }

ZTK
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000