Alteryx Designer Desktop Discussions

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

Group based on the different fields

RM_XYRETLA
Átomo

This is my first post as I am struggling to find solutions via google and other posts. I want to group the records based on pre-defined rules. Please see the rule and expected results below. The challenge to me is that the rule is based on different fields in the data i.e. color and quality, color and size, size and quality. Thank you in advance!!!

 

Rule: 

Rule
ConditionGroup
Color = Green, Quality = Bad1
Color = Blue, Size = L2
Color = Red, Quality = Good3
Color = Yellow, Size = M4
Size  =  S, Quality = OK5

Results to achieve:

ColorSizeQualityGroup 
GreenMBad1
BlueLOK2
BlueLOK2
RedSGood3
RedLGood3
GreenMBad1
BlueLOK2
YellowMOK4
RedSOK5
5 RESPUESTAS 5
Cremo
Meteoro

Hi @RM_XYRETLA ,

 

you could use a simple Formula tool with the specified conditions defined in a IF-THEN-ELSE structure. You could give a look at the attached workflow. Hope it helps :)

 

Screenshot 2024-05-06 113306.png

ChrisTX
Aurora

How many Rules do you have?  A small enough number, where an IF function would be easy to write and maintain?

 

If you have many Rules, I'm guessing you're asking about a how to configure a Dynamic IF function... Consider using a macro, where you would replace the inner XML of an IF function within a Formula tool.

 

Can you post sample input and expected output? 

 

Here are a few posts about updating XML using a batch macro:

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Dynamic-Transpose-Key-Field-Summary-Fi...

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/List-box-with-Transpose/td-p/514539

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Unknown-Select-Feature-w-Summarize-Too...

 

Start by becoming familiar with the XML structure of the Function you'll need to use.

Under Options > User Settings > Edit User Settings > Advanced, check the box for Display XML in Properties Windows.

Then you can see the XML for each tool.

 

Screenshot 2024-05-06 054750.png

 

Screenshot 2024-05-06 054439.png

Chris

 

RM_XYRETLA
Átomo

Thank you for the help. The example I provided was just a simple demo of what I tried to achieve. @ChrisTX, you are right. In the real dataset, there are 14 fields (so the comb can be indefinite). The rules (use a mapping table to redefine fields and values) can be 100+, based on values from the combination of any two of those 14 fields. Sounds like it will be a challenging task to me to learn a new trick. 

 

 

ChrisTX
Aurora

@RM_XYRETLA  please don't drip feed the test cases. It's not good for anyone's time.

 

If you have a complete list of test cases, provide them.

 

All the best,
Chris

danilang
19 - Altair
19 - Altair

Hi @RM_XYRETLA 

 

This looks like a good case of the Dynamic Replace tool.  You can configure the rules as the left input.   The main caveat is that the all the rules are applied to all the rows in order, so if you have nested rules you need to have the most restrictive one at the end of the list.  For example.  If rule 1 is f1=A and f2=B then YY and rule 2 is f1=A and f2=B and f3 =C then ZZ, you need to make sure that rule 2 comes after Rule 1.

 

Dan  

Etiquetas