Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using a flag to count

Below is the logic I am using.

It is flagging the two cells that are white under MOP2. 

I was hoping that on line two after the INV','_', would work but no luck

**** (Match(MOP2,'FACI','PRIV','GUAR','CASH','CHRG','INV',' ',

What Can I use to exclude the blank cells?

  if((Match(MOP,'FACI','PRIV','GUAR','CASH','CHRG','INV')<1 and ElecAdj = 0 ) or

(Match(MOP2,'FACI','PRIV','GUAR','CASH','CHRG','INV',' ',)<1 and ElecAdj2 = 0),1,0) as Flag,

1 Solution

Accepted Solutions
santiago_respane
Specialist
Specialist

Hi,

using the len and the trim function you may achieve what you need.

Example (new code in bold):

  if((Match(MOP,'FACI','PRIV','GUAR','CASH','CHRG','INV')<1 and ElecAdj = 0 ) or

(Match(MOP2,'FACI','PRIV','GUAR','CASH','CHRG','INV',' ',)<1 and len(trim(MOP2)) >0 and ElecAdj2 = 0),1,0) as Flag,

What they do:

Trim: Remove white spaces from beginning and end of a specific value

Len: Return the length in characters of a specific value

Combining these two functions we avoid nulls and blanks, as both return zero in its length when trimmed.

Please let me know if this helps.

Kind regards,

View solution in original post

5 Replies
vinieme12
Champion III
Champion III

Is it really blank! Try len(MOP2)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

some are blank and some have a something in it but can see it Maybe a space?

santiago_respane
Specialist
Specialist

Hi,

using the len and the trim function you may achieve what you need.

Example (new code in bold):

  if((Match(MOP,'FACI','PRIV','GUAR','CASH','CHRG','INV')<1 and ElecAdj = 0 ) or

(Match(MOP2,'FACI','PRIV','GUAR','CASH','CHRG','INV',' ',)<1 and len(trim(MOP2)) >0 and ElecAdj2 = 0),1,0) as Flag,

What they do:

Trim: Remove white spaces from beginning and end of a specific value

Len: Return the length in characters of a specific value

Combining these two functions we avoid nulls and blanks, as both return zero in its length when trimmed.

Please let me know if this helps.

Kind regards,

vinieme12
Champion III
Champion III

I would purge the garbage characters during load using purgechar ()

PurgeChar and KeepChar Functions

Preferably also replace null values with "n/a" or some text

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

Great thank you, Now I have a new problem.

Its counting the top two and it should not.

If there is an MOP2 it can be MOP can have a  1 or 0 in ElecAdj. and then if there is a zero in ElecAdj2 has a zero count it if a 1 do not count it/