Free Trial

Foro

HELP: How to access previous rows with Multi-Row Formula in Alteryx?

ms2023
Átomo

Hi,

I'm currently working on a data processing workflow in Alteryx and I'm facing an issue with accessing values from previous rows using the Multi-Row Formula tool. I'm seeking guidance and assistance on how to achieve this.

My specific scenario is as follows:

  • I have a dataset with multiple columns, including a unique identifier and timestamp column that determines the row order.
  • I want to compare the values in a specific column with the values from the two previous rows.
  • If the current row value matches the values from both of the previous rows, I need to perform some calculations or apply a condition.

I have tried using expressions like [Column:-2] or LAG([Column], 2) within the Multi-Row Formula tool, but it seems these approaches are not supported in Alteryx.

I would greatly appreciate any guidance, suggestions, or alternative approaches that could help me achieve this. If you have encountered a similar situation or have expertise in using the Multi-Row Formula tool, I would love to hear your insights.

If needed, I can provide more specific details about my dataset structure or sample data.

Thank you in advance for your assistance!

4 RESPUESTAS 4

Hi @ms2023 , when you open the Multi-row formula, you'll see in the middle of the configuration window three tabs: Variables, Functions and Saved Expressions. You can use Variables to point to your column values in previous rows. When you select a column in a previous row, it will appear this code in the expression window: [Row-1:Vendor Code] (if the column name is "Vendor Code"). You can just change the -1 to -2 or any other negative or positive number to point to any row in that column, or change the column name to point to any other variable. 

 

In terms of changing the behavior of the expression, you can go to the Expression tab and select the function that suits your needs. If an "If-else" statement is what you need, when you click in the "Conditional" list, you'll see this expression: IF c THEN t ELSE f ENDIF.

 

Using these two tabs, you can build an expression like the following, that might help you:

IF [Row-1:Vendor Code]=[Vendor Code] AND [Row-2:Vendor Code]=[Vendor Code] THEN 1 ELSE 0 ENDIF

 

But to make this instruction work, you'll need to change the "Num Rows" at the top of the configuration window to 2, as it is only in 1 by default.

 

Just to remind you, you can also make these questions in Spanish if that's easier!

 

multirow.png

  

FláviaB
Alteryx Community Team
Alteryx Community Team

Hola @ms2023! Gracias por compartir tu duda. Recuerda que como estamos en la comunidad española, te pedimos que te comuniques en español para que otros usuarios también puedan entender y participar en la conversación. 

@IgnacioVilaplana, gracias por tu ayuda! 

Flávia Brancato
ms2023
Átomo

@IgnacioVilaplana Muchas gracias por la respuesta, funcionó sin problemas. Y perdón por la confusión en el idioma. 

FláviaB
Alteryx Community Team
Alteryx Community Team

@ms2023, no tiene por qué pedir disculpas. Me alegra saber que pudiste resolver su problema. Cuando puedas, no olvides marcar la respuesta que te ayudó como solución, así estarás ayudando a otros usuarios que tienen la misma duda. Muchas gracias! 😊

Flávia Brancato
Etiquetas