Skip to main content
Question

How to count the amount of times a value is present

  • February 14, 2014
  • 3 replies
  • 306 views

Forum|alt.badge.img
Hi there,

 

 

What I have is a dataset with a field named UPDATE. in this field, there are many differant values populated. Here's an example (imagine each line is an entry in the dataset table):

 

 

UPDATE

 

DESCRIP ; E_MAIL ; TEL_NR ; WEBSITE

 

E_MAIL ; WEBSITE

 

DESCRIP ; WEBSITE

 

E_MAIL ; TEL_NR ; WEBSITE

 

DESCRIP

 

DESCRIP ; TEL_NR

 

 

etc.. Please not that these multiple values (like DESCRUP ; E_MAIL) are contained in a single attribute.

 

 

So what I want as a result is to calculate how many times a set of specified values are present:

 

 

UPDATE                         COUNT

 

DESCRIP                      4

 

E_MAIL                          3

 

TEL_NR                        3

 

WEBSITE                      4

 

 

Currently my writer is an xls table, but I've had very little luck in achieving this output.

 

 

Any kind of help would be fantastic.

3 replies

fmelizard
Safer
Forum|alt.badge.img+18
  • Safer
  • February 14, 2014
Hi,

 

One way to do that would be to:
  1. Split the UPDATE attribute > AttributeSplitter set on ;
  2. Clean list elements > StringReplacer text to find: ;|" ", replacement text " ",  use regular expressions: yes
  3. Explode list > ListExploder
  4. Aggregate > Aggregator group by _list , set a count attribute (_count)
There are probably other ways.

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • February 14, 2014
Staying fully in listtransformers u can

 

 

remove spaces->split on ";"->eplode list->build list grouped by  "_list" (assuming you didnt rename default)->listelementcounter on "_list"-> remove list.

 

Now u have atribute and its count.

Forum|alt.badge.img
Thanks guys, I just tried both methods, and they work beatifully!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings