Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Dynamically create new fields with null values

Newt
8 - Asteroid

I am comparing values for a few dozen fields, this month vs. last month.  

 

When there's a new item this month, there is no "last month field" to compare it to.

This crashes the flow when the logic tries to compare "Sales" with "Sales Previous Month"... since the Sales Previous Month field does not exist for new items.

 

For items with no previous month, how can I create a dynamically changing set of fields for last month, with null or zero values?  I'd Append this empty set to the current month's fields.

 

I'd like this to be dynamic because the users likely will decide to monitor different fields as time passes.

 

Thanks for any help!

3 REPLIES 3
Qiu
21 - Polaris
21 - Polaris

@Newt 
Is it possible for you to provide sample input files and sample output?

Yoshiro_Fujimori
15 - Aurora
15 - Aurora

Hi @Newt ,


If the column names follows a specific rules like [name] vs. [name_Previous], you can use Cross Tab as below.

 

Input Data

RecordIDItemAItemA_PreviousItemBItemB_PreviousItemC
11011202210
22022404220
33033606230
44044808240
5505510010250

 

Output Data

RecordIDNameCurrentPreviousDiff
1ItemA1011-1
1ItemB2022-2
1ItemC10  
2ItemA2022-2
2ItemB4042-2
2ItemC20  
3ItemA3033-3
3ItemB6062-2
3ItemC30  
4ItemA4044-4
4ItemB8082-2
4ItemC40  
5ItemA5055-5
5ItemB100102-2
5ItemC50  

 

Workflow

CompareCurPrevWithNull.png

 

Formula Tool
[Cur_Prev] = IF EndsWith([Name], "_Previous") THEN "Previous" ELSE "Current" ENDIF
[Name] = REGEX_Replace([Name], "_Previous$", "")

dreldrel
8 - Asteroid

I like your idea @Yoshiro_Fujimori! I used to use Python tool to address this kind of task, but now I have a much easier to do it :) 

Labels
Top Solution Authors