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

Conditional Values (Formula)

Yeonsujen
8 - Asteroid

Hello All,

I need some help with changing values depending on the given condition below.

I've made a new "Code" column where Name A = Code 1, Name B = Code 2, etc. with the following formula:

IF [Name] = "A" then "1"
elseif [Name] = "B" then "2"
elseif [Name] = "C" then "3"
elseif [Name] = "D" then "4"
elseif [Name] = "E" then "5"
elseif [Name] = "F" then "6"
elseif [Name] = "G" then "7"
else "0" endif

This repeats on a monthly basis:

DateNameAmountCode
2021-07-31 00:00:00A1001
2021-07-31 00:00:00B1002
2021-07-31 00:00:00C03
2021-07-31 00:00:00D1004
2021-07-31 00:00:00E1005
2021-07-31 00:00:00F1006
2021-07-31 00:00:00G1007
2021-08-31 00:00:00A1001
2021-08-31 00:00:00B1002
2021-08-31 00:00:00C1003
2021-08-31 00:00:00D1004
2021-08-31 00:00:00E1005
2021-08-31 00:00:00F1006
2021-08-31 00:00:00G1007

 

However, now I have a new condition where if Name "C" has Amount "0" then the Code for Name "A" needs to be "11". This also needs to take the dates into consideration as some monthly dates may have Name "C" with an Amount greater than 0 and can remain with the same Code "1".

Essentially, I need to get the following output:

DateNameAmountCode
2021-07-31 00:00:00A10011
2021-07-31 00:00:00B1002
2021-07-31 00:00:00C03
2021-07-31 00:00:00D1004
2021-07-31 00:00:00E1005
2021-07-31 00:00:00F1006
2021-07-31 00:00:00G1007
2021-08-31 00:00:00A1001
2021-08-31 00:00:00B1002
2021-08-31 00:00:00C1003
2021-08-31 00:00:00D1004
2021-08-31 00:00:00E1005
2021-08-31 00:00:00F1006
2021-08-31 00:00:00G1007


Please let me know how I can solve this!

7 REPLIES 7
Christina_H
14 - Magnetar

See attached.  I've used a mapping table rather than an if formula to assign the original codes but the rest of the process will still apply if you prefer a formula.

JoeHerbert
Alteryx Alumni (Retired)

Hi @Yeonsujen , I've used some summarises & a formula to create the New_Code, column you are after, enjoy, Happy solving 😄 

JoeHerbert_0-1635438542062.png

 


Joe 

JoeHerbert
Alteryx Alumni (Retired)

Much smoother from @Christina_H 

Yeonsujen
8 - Asteroid

@Christina_H Thank you for your response, it worked perfectly! 🙂

@JoeHerbert Thank you as well for your response! It also worked and agree with the above that Christina's is smoother. Always interesting to see different methods regardless!

atcodedog05
22 - Nova
22 - Nova

_

Christina_H
14 - Magnetar

@Yeonsujen I think this is a simple fix - you need to change the join tool to join by both date and employee ID

Christina_Hurrell_0-1635509641073.png

 

Yeonsujen
8 - Asteroid

@Christina_H Sorry I edited my comment before! Yes this helped to fix it in the end, thank you again! 🙂

Labels