Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How can I sort a database in two groups ?

KhaledF
6 - Meteoroid

Hi all

I'm looking for sort a database in two groups :

If the digits on the "Phone Number" column equal "9 digits" put it in one group.

If the digits on the "Phone Number" column less than "9 digits" put it in other group.

 

Main Database

Name 

Phone Number

A

545567831

 

234245643

 

4356

 

432134256

 

246

 

7356483

 

Desired result

 

Group (1)

Name

Phone Number

A

545567831

B

234245643

D

432134256

 

Group (2)

Name

Phone Number

C

4356

E

246

F

7356483

 

Thanks for all.

7 REPLIES 7
BrandonB
Alteryx
Alteryx

You can use the Length() function in the formula tool to determine the length of a string in conjunction with an If statement to create the groups. Here is an example:

 

Output Column in formula tool: Group

 

IF Length([String]) = 9

THEN 1

ELSEIF Length([String]) < 9 

THEN 2

ELSE Null()

ENDIF

 

 

atrozz
8 - Asteroid

Hello. The answer is it workflow. If you need only a group, use a filter tool by 'Groups' Field. Good Luck!!!

KhaledF
6 - Meteoroid
Thanks for your help.

But I couldn't do it in Alteryx, can you please share the way.

Thanks.
KhaledF
6 - Meteoroid
Thanks its helpful

Is there away to make the different two group in a separate sheets.

Thanks
atrozz
8 - Asteroid

Hello. No, all the data its possible in the same sheet (or in distinct sheets), like this.

order 1.png

And the workflow like this:

order 2.png

If you have the data in differents files, only use Union Tool to unify the datas. If you have the data in differents sheets, apply Unión tool too. If you have the data in the same file/sheet, with my workflow your obtain the answer like the result.

If you need the groups in differents outputs (sheets, files, tables, etc), use filter tool to separate the groups, like this.

order 3.png

Regards!!!

KhaledF
6 - Meteoroid

This is what i am looking for.

 

Thank you so much :)

 

 

atrozz
8 - Asteroid

You welcome and good luck ;)

Labels
Top Solution Authors