Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

How to dynamically sum to always output the same fields even if the field is not in data?

KTam0916
5 - Atom

I have data that looks like:

 

OrderTypeValue
xyz_1A2100
xyz_2B430
xyz_3C51
xyz_4C783
xyz_5B5441
xyz_6B1025

 

The data may not always have all 3 types of orders A/B/C - on some days, it could be only A/B, or B/C etc. For example:

 

OrderTypeValue
xyz_1A2100
xyz_3C51
xyz_4C783

 

Nonetheless, I would like to sum up the total value in such a way that it ALWAYS outputs as, even if one of the types is not present (and as such it should be summed as 0), like so:

ABC
21000834
 

I currently use a sum -> cross tab -> sum, and it works to a degree that it is able to sum up the data correctly but my output would just look like the table below, and it makes it impossible to run the rest of my workflow since a field (B) is missing.

 

AC
2100834

 

Appreciate any help, thank you! 

1 REPLY 1
gawa
16 - Nebula
16 - Nebula

hi @KTam0916 The simplest way is to union the dummy data(see below) to the input data, and Cross-tab. 

TypeValue
A0
B0
C0

 

By doing so, all of type will appear at headers after Cross tab regardless of input data having all of types or not.

I frequently use this technique to maintain the same schema after Cross-tab.(Otherwise missing fields will cause error after cross tab tool)

image.png

Labels