Alteryx Designer Desktop Discussions

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

Add rows with different suffices - Multi row formula

G_SAND
8 - Asteroid

Hi

 

I have a set of data where there are some fields I want to add together but they have different suffices:

 

MaterialBatchValue
A1X1
A1X-23
A2Y2
A2Y-106
A3Z7
A3Z-64

 

This is what I want the output to look like:

 

MaterialBatchValue
A1X4
A1X-23
A2Y8
A2Y-106
A3Z11
A3Z-64

 

I can't remove the suffix from the data set as there are other batches that need the suffix there, its only when there is a duplicate in the core batch number for the same material. The second batch can stay in the data set as I am summarizing by first batch further in the workflow.

I can use a multi row formula to do the calculation for a specific suffix:

 

If [Row+1:Batch] = [Batch]+ "-2" then [value] + [Row+1:value] else [value] endif

 

So essentially I need the calculation to see any batch with "-" and then any possible character after that - like -* or -x

 

Thanks

7 REPLIES 7
MarqueeCrew
20 - Arcturus
20 - Arcturus
Try this:

Use the multi-row formula with configuration of:

Update the value field
Group on material

[value] + [Row+1:value]

Let’s see if it does what you want with your real data.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Kenda
16 - Nebula
16 - Nebula

Hey @G_SAND!

 

See if the attached v11.0 workflow accomplishes what you're looking for. I used two Multi-Row Formula tools followed by a Summarize and then a Join. Basically, this is creating a counter for ever row that has the same first character in the Batch column. It then sums those up that are in the same group and only keeps the maximum value. The Join at the end is to bring all the data back together. Hope this helps!

G_SAND
8 - Asteroid

I fear I haven't been detailed enough in my first post. Here is some more appropriate data:

 

Current Data

MaterialBatch             Stock
A115493-4SLE0.380
A115493-5SLE22.766
B11917134,317.000
C120313844.770
D1EU2034217.824
D1EU20343398.500
E1132668.211
E113266-22.100

 

The formula needs to identify the same core batch number with a "-" and any suffix afterwards. So it sees 15493-4SLE and 15493-5SLE as the same and 13266 and 13266-2 as the same. Not all the materials will have multiple batches and if the do, not all will have a "-" suffix.

 

This will be the output:

MaterialBatch           Stock
A115493-4SLE23.146
A115493-5SLE22.766
B11917134,317.000
C120313844.770
D1EU2034217.824
D1EU20343398.500
E11326610.311
E113266-22.100

 

The only ones to be added together are A1 and E1.

 

Further in the workflow I only keep the first batch so I end up with this:

MaterialBatch            Stock
A115493-4SLE23.146
B11917134,317.000
C120313844.770
D1EU2034217.824
E11326610.311

 

I can't focus on the first 5 characters as that would mean the values for D1 would also be combined.

 

Hope this clarifies.

Kenda
16 - Nebula
16 - Nebula

@G_SAND In my previously attached workflow, change the first Multi-Row Formula tool to say this:

iif(REGEX_Replace([Row-1:Batch], "(.*?)\-.*", "$1")=REGEX_Replace([Batch], "(.*?)\-.*", "$1"),[Row-1:NewField],[Row-1:NewField]+1)

Then, in the second Multi-Row Formula tool, make sure NewField2 is a double since you have decimals (and the field you're adding is a double as well, here 'Stock'). The rest should be fine as it was. Hopefully this solves your predicament. 

hey dude,

 

Here I attached my workflow. Let me describe little bit about it.

First, I create some formula to decide which material contain '-' values.

After I know which material has same materials, then I total up the stock based on the materials

Take a look at the workflow. Hope it solved your problem.

danrh
13 - Pulsar

You should be able to do it with the below:

image.png

The Multi-Row Formula tool checks if everything before the "-" is the same as the previous row.  If it is, it changes the Batch to equal the previous Batch.  Then a simple sum and presto!

G_SAND
8 - Asteroid

Thanks @danrh

 

I'm sure the others work as well but I am going for this one.

 

Thanks

Labels