Alteryx Designer Desktop Discussions

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

multi-row formula?

Shelley5683
7 - Meteor

I am need to add the column "Code Change" after determining what tickets were changed or not changed. I need the "Code Change" column only to reflect the comment on the line that was changed/not changed. To determine if the ticket code has changed, I am using the "Units" column to identify if there is a positive and negative for the same ticket and code. If there is then the ticket has a code change and the "new line" will need to reflect the comment. If the "Units" column doesn't have a positive and negative for the same ticket and code then it will need to reflect "no change". Suggestions for best solution?

 

Visit DateTicket NumberCodeUnitsProviderCode Change

4/12/2019

439315

99214

1

Jane Doe 
4/12/201943931599214-1Jane Doe 
4/12/2019439315992131Jane DoeUp Code
4/12/2019439326992131John Smith 
4/12/201943932699213-1John Smith 
4/12/2019439326992141John SmithDown Code
4/12/2019439324992031Jill HillNo Change
4/12/2019439339992021Sam SillyNo Change
6 REPLIES 6
Thableaus
17 - Castor
17 - Castor

Hi @Shelley5683 

 

See if this works for you:

1213.PNG

 

IF ([Row-1:Units] = -1 AND [Units] = 1) AND ([Code]< [Row-1:Code]) THEN "Up Code"
ELSEIF ([Row-1:Units] = -1 AND [Units] = 1) AND ([Code] > [Row-1:Code]) THEN "Down Code"
ELSEIF IsNull([Row-1:Code]) AND IsNull([Row+1:Code]) THEN "No Change"
ELSE "" ENDIF

 

Cheers,

Shelley5683
7 - Meteor

Thank you for the help @Thableaus the Down Code is working, however the Up Code and No Change doesn't. The information is being sorted by visit date, ticket and then code. I also have another scenario to add - if the ticket shows  1 "units" and -1 "units" and no other code is added, then it needs to reflect "invalid code".

Below is the results I received using the formula you provided.

 

 

Appreciate your help!

Shelley


Code Change Results.PNG

Thableaus
17 - Castor
17 - Castor

Hi @Shelley5683 

 

Take a look at full Multi-Row configuration with attention.

 

You need to Group By "Ticket Number" and set "Values for Rows that don't exist" option to NULL. Be sure you're doing that, otherwise it won't work as expected, ok?

 

To add Invalid Code result:

 

EDIT:

 

IF ([Row-1:Units] = -1 AND [Units] = 1) AND ([Code]< [Row-1:Code]) THEN "Up Code"
ELSEIF ([Row-1:Units] = -1 AND [Units] = 1) AND ([Code] > [Row-1:Code]) THEN "Down Code"

ELSEIF (IsNull([Row-1:Units]) AND [Units] = 1 AND [Row+1:Units] = -1)  THEN "Invalid Code"
ELSEIF IsNull([Row-1:Code]) AND IsNull([Row+1:Code]) THEN "No Change"
ELSE "" ENDIF

 

Shelley5683
7 - Meteor

@Thableaus 

 

I do have these grouped by ticket but I did not have this changed ("Values for Rows that don't exist" option to NULL) but have corrected that. The No Change, Down Code and Invalid Code work, but still not receiving Up Code messages. For the Invalid Code, I am receiving this message within a ticket that is also tagged Down Code. I only need this to reflect the Invalid Code if the ticket only has 2 lines (a line that is negative and a line that is positive), not sure if I can use the multi-row formula tool for this. I did notice that on the ones that should be tagged as Up Code, has 3 lines and the first 2 lines have positive units and the last has a negative. Can I compare the last 2 lines for the -1 and 1 versus the first 2 lines?

 

Code Change Results.PNG

Thableaus
17 - Castor
17 - Castor

@Shelley5683 

 

Ok, as far as I want to help you out, I kindly ask that you provide me all the possibilities and rules for this to work.

Otherwise, we'll never finish this topic.

 

WorkflowCode121.PNGI changed the flow and divided it into 2 steps. I thought it would be better to work this way.

- Added a Record ID

- Added a Summarized Tool to see which records have code variation

- Sorted by Record ID 

- Used Multi-Row Formula Tool to check if it's Up Code or Down Code with formula:

IF [Max_RecordID] > [Row-1:Max_RecordID] AND [Code] < [Row-1:Code] THEN
"Up Code"
ELSEIF [Max_RecordID] > [Row-1:Max_RecordID] AND [Code] > [Row-1:Code] THEN
"Down Code"
ELSE "" ENDIF

 

- Filtered only Up and Down code

- Joined that to original dataset to bring Code Change (used a Left Join)

- Sorted again by record ID to put things in order

- Multi-Row Formula Tool to update the Code Change Field.

Used the follow formula:

IF IsNull([Row-1:Units]) AND IsNull([Row+1:Units]) THEN "No Change"
ELSEIF IsNull([Row-1:Units]) AND IsNull([Row+2:Units]) AND [Code] = [Row+1:Code] THEN "Invalid Code"

ELSE [Right_Code Change] ENDIF

 

* The Invalid code I supposed that IF row before is null (no value), two rows after is null too (no value) and Code = Row +1 Code then this is an Invalid Code.

 

The full workflow is attached on version 2018.4

 

Cheers,

Shelley5683
7 - Meteor

@Thableaus with just a couple modifications this solution works for what I needed to capture. I greatly appreciate all of your assistance! Have a great day!

 

Thank you,

Shelley

Labels