Repeat action help

Hello,

I'm trying to simply do a repeat on a single action. (Before doing something more complicated, I would like to test)
I've made a specific example for that, because I can't make my process works.

With a simple modify column, on a simple column, removing text on conditions.
If it contains this text and this text, or this text and this text, so remove this one.
It's like 'text1,text2,text3,text4' -> If it contains "text4", remove "text4".
And there is a condition inside to remove all the comma.
I need to to this multiple times on the same column, to finally have only one word, without comma.
That is why I need to use a repeat.

But, I can't make it works multiple times ?
What I understand with the repeat action is : I need to repeat my process until something.
So in the action, there is "Until result table is empty".
Perfect, if I put a derived table on condition, when the condition is not met, it will be empty.

I use the input action in the repeated module to get my rows :

This is my repeated module, where you can see my condition inside the derive table (if any row has a comma) :

In my case, I need to do the modify column 4 times to have a result without any comma inside.
This process works only 1 time.
If I put multiple times my modify column, it works well (so without the repeat).

Of course, I would like to retrieve the last processed values.
Here I retrieve the values, but after 1 "Repeat" done.

Am I using wrong the conditions for the derive table, or the repeat condition and mode ?

Thank you for you help.

Hi Windblast,

I am just another community user like yourself. Out of curiosity is the text that you are looking for always in a certain position? Does the length vary?

For example, where you write ''text1,text2,text3,text4' -> If it contains "text4", remove "text4".'
Are you always trying to get to text1 without the comma as the final result? Or do you need to find an unknown text string at different positions when separated by the comma? How would you know the correct one to select for?

Easymorph has a text function called 'keepbefore' which will let keep all the text in the string up until the specified delimiter value. And you can feed the expression an occurrence count if you need to keep up to a certain position in your list. If text you are looking for can vary in position though, you probably wouldn't want to use this.

If your list can have different lengths and you are trying to loop or repeat an action, how would you know when you want it to stop? Or how would you know you have found the correct substring?

If you have a bunch of conditions that you are looking to check for, then you might be able to use the rule action. Create all of your conditions for checking the rule within the string and then based on satisfying the condition, replace the value with any string you want and you don't need to have a comma included.

So far, I am not immediately seeing why you need to specifically repeat any actions. Do you have a slightly more concrete example of your use case by chance?

Hi @WindBlast ,
I'm not really sure what it is you are starting with and what your desired result would be.

If you have a field containing "text1,text2,text3,....textX" and are trying to get just "text1" then as @Perk suggested, there is the keepBefore() function which you can use either to calculate a new column or to modify the existing one:

keepBefore([MyField], ",")

If this isn't what you are trying to achieve, can you share your simple example and some more information?

Regards
Matt

Hello,

Okay I will do it with a current example.
Just take a note : for now I have just a little concatenation of string, but it could be a lot more in the future.

I have multiple columns, and after applying multiple rules, I have one field with multiple strings inside, separated with a comma :
image
This string could become a lot bigger than that.

Depending on the values present inside this concatenate string, we have to make a selection rule, finally get only one word inside this string.
Of course, for now I can use a rule action to perform my needs, but I would like to make an if statement.
Why ?
Because actually, it could have only a little number of values.
But, if tomorrow I have 50 values, I don't want to have a statement like :
"if [Data] contains "a text" and contains "a other text" and contains "an other" and contains "an other"....."
I would like to remove the different text values, depending on conditions, to remove step by step the unwanted values.

For example in the code below, in the first case, I want to remove the "NOT LISTED" value, if the [Data] contains "DUAL USE".
It works, but if I do that, the rest of the if statements are not applied.
-> Same with the action "rules", if the first statement is applied, the others are not.
That's why I would like to do a repeat on this action, to remove a text on condition, repeat it, remove an other text with an other condition, 50 times if needed, until I know I can't have more than one value in the result.

if( contains([Data], 'DUAL USE') and contains([Data], 'NOT LISTED'),
    removetext([Data], 'NOT LISTED'),
    if(contains([Data], 'DUAL USE'),
        'DUAL USE',
        if( contains([Data], 'LISTED'),
            'LISTED',
            if( contains([Data], 'NOT LISTED'),
                'NOT LISTED',
                if( contains([Data], 'NOT ASSESSED'),
                    'NOT ASSESSED',
                    [Data]
                )
            )
        )
    )
)

Of course in last condition, it must have a last validated value, which will become the only value in the field.

@Perk in response to :
If your list can have different lengths and you are trying to loop or repeat an action, how would you know when you want it to stop? Or how would you know you have found the correct substring?

-> The values are not always in the same order, but I know every possible values that could be the "last" value. So I can say "if the value is only that, so the value stay that".

It's like a for loop :

counter = 0;
for (i = 0, i<10, i++) {
  counter ++;
  if (counter > 2){
    counter = 2;
  }
}

I can repeat the action 10 times or 100000 times if I want, the result will be the same at the end, because of my last condition.

I want to repeat X times the process on my field, and if there is only 1 value in the result, I keep this value.

I hope it's more clear with these examples.

@Perk For the stop condition that I use in this case :
If there is a comma left in the field, so there is multiple values inside, and I need to loop again.
If there is no comma in the field, I can stop the loop, because there is only one value in the result field, that's what I want.

That's why I used a derived table, with this condition : the table is not empty if there is a comma in the field.
It should continue to repeat the action, until this result table is empty.
But it doesn't, it stop after one process.

Could you solve this using LET in the expression instead? So the expression becomes:

LET Value = if( contains([Data], 'DUAL USE') and contains([Data], 'NOT LISTED'), removetext([Data], 'NOT LISTED'), [Data])

if(contains(Value, 'DUAL USE'),
    'DUAL USE',
    if( contains(Value, 'LISTED'),
        'LISTED',
        if( contains(Value, 'NOT LISTED'),
            'NOT LISTED',
            if( contains(Value, 'NOT ASSESSED'),
                'NOT ASSESSED',
                Value
            )
        )
    )
)

You can have as many of the LET statements as necessary, performing all of the combinations needed to remove text values referencing the previous:

LET Value1 = if( contains([Data], 'DUAL USE') and contains([Data], 'NOT LISTED'), removetext([Data], 'NOT LISTED'), [Data])
LET Value2 = if( contains(Value1, 'LISTED') and contains(Value1,'NOT LISTED'), removetext(Value1, 'NOT LISTED'), Value1)

if(contains(Value2, 'DUAL USE'), ......

Doing it based on if there are commas still present is problematic as the removetext isn't removing the comma also. And doing so is a little complex as you don't know if the comma will be before or after depending on its position in the string.

1 Like

I didn't know using LET to store values was possible.
If it works like that, so yes it's a good alternative to my needs.
Instead of having one big expression with a lot of "if" and repeat it, I will be able to make it more clear, and step by step.
It allows me to remove specific text one by one depending on conditions.

Well, it seems to be really good, it's what I want.
I will tell you if I have any problem with it.

Thank you.

1 Like

:+1:

You can find info on LET as well as other more advanced expression syntax (e.g. ASSUME) here: syntax:operators [EasyMorph Help]