Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

Breaking numbers down

$
0
0
So, I have to deal with these account numbers that are like xxx or xxx.yy or xxx.yy.zz
They're all levels, actually... like account 550.10 will have 550 as parent.
I was thinking of a way to break them, first using replace in string. But then, I realized that regex on that doesn't quite do what I need. I had set this up:
Code:

In stream field    Out stream field    use RegEx    Search    Replace with    Replace with field    Whole Word    Case sensitive
CONTA    conta_lvl1    Y    (\d{3}).*    $1        N    N
CONTA    conta_lvl2    Y    \d{3}\.(\d{2}).*    $1        N    N
CONTA    conta_lvl3    Y    \d{3}\.\d{2}\.(\d{2})    $1        N    N

Problem is: in a lvl1 account, I'll get lvl2 and lvl3 fields with the same number, instead of null as I thought it should be...
get's worse with accounts that are lvl 2, 'cause they'll have the lvl3 field the same as lvl1 (the full number, like 550.10), so I needed to create a new "verify" field...
Code:

In stream field    Out stream field    use RegEx    Search    Replace with    Replace with field    Whole Word    Case sensitive

CONTA    verifica_lvl3    Y    \d{3}\.(\d{2})\.(\d{2})    $1\.$2        N    N

and then, the transformation got spammed by if filters and set values to constant nulls.

Is there a smarter way of doing this that I'm not realizing?

=edit=
am I missing or doing something wrong here? An account like 999.01.01 will return lvl1 field as 999, lvl2 field as 01, and a null lvl3 field - when it should be 01...

=edit 2=
and now I've got a new doubt: not just breaking down, but grouping them back up - again, the smarter way possible. Problem here is: accounts are grouped by their lvl1, but not 123.01 goes to 123, it goes to 120.

Viewing all articles
Browse latest Browse all 16689

Trending Articles



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