Adding total for variable number of fields
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
But I want to decide which fields to total by using another table.
Let's say i have the dataset below:
fieldA | fieldB | fieldC | value |
A | A | A | 0,21 |
A | A | B | 0,15 |
A | B | A | 0,31 |
A | B | B | 0,45 |
B | A | A | 0,55 |
B | A | B | 0,65 |
B | B | A | 0,41 |
B | B | B | 0,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:
fieldA | fieldB | fieldC | value |
A | A | A | 0,21 |
A | A | B | 0,15 |
A | B | A | 0,31 |
A | B | B | 0,45 |
B | A | A | 0,55 |
B | A | B | 0,65 |
B | B | A | 0,41 |
B | B | B | 0,25 |
Total | A | A | 0,21 |
Total | A | B | 0,15 |
Total | B | A | 0,31 |
Total | B | B | 0,45 |
Total | A | A | 0,55 |
Total | A | B | 0,65 |
Total | B | A | 0,41 |
Total | B | B | 0,25 |
A | Total | A | 0,21 |
A | Total | B | 0,15 |
A | Total | A | 0,31 |
A | Total | B | 0,45 |
B | Total | A | 0,55 |
B | Total | B | 0,65 |
B | Total | A | 0,41 |
B | Total | B | 0,25 |
Does anyone have an idea how to proceed?
Thanks a bunch!
Mikis
Solved! Go to Solution.
- Labels:
- Preparation
- Transformation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
brilliant, thanks a lot!
It does exactly what I need, now I'll figure out why it works :)
