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

Add Subtotal and grand total based on the category

Lakshraj
8 - Asteroid

Hi Team,

 

Hope everyone is well and safe,

 

Am just trying to add a subtotal by category wise but not happening. Its very simple like below. Can anyone help me ?

 

Raw table :

 

Category2015201620172018
Apple2141916
Mangoes10222724
Banana18303532
Tomatoes38505552
Onion46586360
Peace54667168
Ginger62747976

 

Expected output

Category2015201620172018Grand total
Apple214191651
Mangoes1022272483
Banana18303532115
Total Fruits30668172249
Tomatoes38505552195
Onion46586360227
Peace54667168259
Ginger62747976291
Total Vegetable200248268256972
Grand total (Fr+Veg)2303143493281221
6 REPLIES 6
dpencheva
8 - Asteroid

Hi I hope my suggestion will help you! I use formula tool to create variable "Is_Fruit" but it can be replace with Join tool or Find and Replace tool if there is a dataset with many records.

grossal
15 - Aurora
15 - Aurora

Hi @Lakshraj,

 

I wasn't able to dynamically place the 'Total Fruits' and 'Total Vegetable' in the right spot, but I was able to make it independent of additional years and added an extra Input for easy editing of the Fruits/Vegetables list. It's not really pretty, but I wanted to give it a shot.

 

grossal_0-1587917162417.png

 

 

Output:

grossal_1-1587917186886.png

 

You might be able to get the position right with a couple Filter Tools, but this would make the workflow even more complicated and it already looked unnecessary complicated. Someone else will probably come up with an easier and more dynamic approach, but let me know what you think anyway.

 

Workflow attached.

 

Best

Alex

grossal
15 - Aurora
15 - Aurora

I made some additional changes to dynamically place the subtotals in the right spot:

 

grossal_0-1587917690092.png

 

Result:

grossal_1-1587917702597.png

 

It's a bit sketchy because I use 100 000 000 as a RecordID for the Grand total to place it at the bottom. I expect that you won't have more than 100 Million categories and run into an issue with this. 

 

Updated Workflow attached. Let me know what you think.

 

Best

Alex

Lakshraj
8 - Asteroid

Amazing thank you so much , it worked. :). i have one more quick request - my formula column is updating even in blank cells. Is there a way to resolve it ?

 

Like I used "If" condition and Else means update as "XXX". So these "XXX" is getting updated in blank rows as well.

grossal
15 - Aurora
15 - Aurora

I would do it the way you suggested it:

 

IF isnull([Your Column])
THEN XXX
ELSE [Your Column]
ENDIF

 

grossal_0-1587923567437.png

 

Make sure the datatype of your XXX is the same as the rest of the column, but that's it.

 

Alex

 

dinesha
6 - Meteoroid

i have added one another data set with group id 

 

Labels