Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Adding total for variable number of fields

Mikis
8 - Asteroid

Hello everyone,

 

I have a dataset that is going through a series of calculations, but I struggle with adding the total for certain columns (determined by my user).

The easiest and most flexible way I can think of is appending the dataset to itself and adding 'Total' to fields to total.

I could hard code this by using the formula tool and union like below:

example.PNG

But I want to decide which fields to total by using another table.

 

Let's say i have the dataset below: 

 

fieldAfieldBfieldCvalue
AAA0,21
AAB0,15
ABA0,31
ABB0,45
BAA0,55
BAB0,65
BBA0,41
BBB0,25

 

And my user indicates that these are the two fields for which he wants the total

fieldToTotal
fieldA
fieldB

 

Basically I'd like a table that is three times as large as the original: the original table + the original table where fieldA = 'total' and the original table where fieldB = 'total'. It would look like the following:

 

fieldAfieldBfieldCvalue
AAA0,21
AAB0,15
ABA0,31
ABB0,45
BAA0,55
BAB0,65
BBA0,41
BBB0,25
TotalAA0,21
TotalAB0,15
TotalBA0,31
TotalBB0,45
TotalAA0,55
TotalAB0,65
TotalBA0,41
TotalBB0,25
ATotalA0,21
ATotalB0,15
ATotalA0,31
ATotalB0,45
BTotalA0,55
BTotalB0,65
BTotalA0,41
BTotalB0,25

 

Does anyone have an idea how to proceed?

 

Thanks a bunch!

Mikis

4 REPLIES 4
ponraj
13 - Pulsar

Attaching sample dynamic workflow for your case assuming that there will be only two input fields from your user. 

Workflow.PNGResults.PNG

Mikis
8 - Asteroid

Hi Ponraj,

 

I'm already impressed, but sadly I don't know in advance how many input fields the user will give me.

The actual dataset contains somewhere between 10 and 15 columns, and I think like 6 or 7 of them should allow for totals.

 

I was thinking in terms of a batch macro? Or do you have another idea perhaps?

 

That being said, your flow does exactly what I need it to!

 

Kind regards,

Mikis

ponraj
13 - Pulsar

Hi Mikis,

 

Here is the dynamic workflow you are looking for!

Workflow.PNG

Mikis
8 - Asteroid

brilliant, thanks a lot!

It does exactly what I need, now I'll figure out why it works :)

Labels