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.
SOLVED

Aligning Inconsistent Field Positions/Names

CGIQV
8 - Asteroid

I've been able to use one of the Crew Macros and bring in a bunch of data from within a directory.  I still have some work to do with formatting this data before I can begin the calculations I need.

 

Below is the way data is currently positioned and the problems I'm facing:

 

FruitStateJanuaryFebruaryMarchOctoberNovemberTotal  
AppleAZ121355129101  
AppleNY229337829225  
AppleCA231962920169  
FruitStateMarchAprilMayTotal    
PearsNY522852132    
PearsOR518685222    
PearsNJ928692270    
PearsPA229966187    
FruitStateSeptemberDecember2019 Total     
LimesFL9196187     
LimesMA473178     
LimesCA8916105     
LimesTX301949     
          

 

When all is said and done, I need values for Fruit/State/Total.

 

FruitStateTotal
AppleAZ101
AppleNY225
AppleCA169
PearsNY132
PearsOR222
PearsNJ270
PearsPA187
LimesFL187
LimesMA78
LimesCA105
LimesTX49

 

My two issues are alignment, and naming for the total column.  It should always contain total, so maybe some sort of contains() formula.

2 REPLIES 2
ashissanpui
9 - Comet

@CGIQV  use arrange and summarize tool to get that.

ashissanpui_0-1578810140627.png

 

ashissanpui_1-1578810163047.png

 

ashissanpui_2-1578810187062.png

danilang
19 - Altair
19 - Altair

Hi @CGIQV 

 

The problem with these kinds of problems is that the columns change from month to month.  You currently have the five month columns, but in the future you may have 4, 6, and the month names may change.  Because of this inconsistency, you need to have a solution that is is dynamic and never references the month column names.  The transpose tool is ideal for this, because it uses Dynamic or Unknown Columns to ensure that any changes to the data columns are includedw.png

First you add a RecordID to sort your final data.  Remove the leading and trailing spaces and the header rows.  Then transpose the quantity columns using the RecordID, Fruit and State as key columns.  After converting the quantity column to integer, sum up the quantities by Fruit and State. After sorting and removing the RecordID column, you're left with

 

r.png

 

Dan

 

 

Labels