Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

Multi-row formula - if statements and averages

bwat2435
7 - Meteor

Hello,

 

I have a dataset that is sorted in ascending order by account and by KM. 

 

If there is a null for Year, I'd like the output to be the average between the last entered year before the null, the the next entered year after the null(s). If a new account code does not have any Year entires at the beginning, the output should take the first year entry that occurs.

 

Please see below an example of my problem and what the desired output is. Can anyone suggest anything? I have attached the below in spreadsheet form.

 

clipboard_image_0.png

 

Thank you!!

 

Bianca

3 REPLIES 3
estherb47
15 - Aurora
15 - Aurora

Hi @bwat2435 

 

You know you've posted a challenging question when there's a long delay in response.

 

I don't know if this is the best or most efficient, but it works.

 

image.png

 

Basically, a long IF/THEN/ELSEIF statement in the first Multi Row formula tool creates a field called column that will be used to tag which rows should be averaged. There were a few challenges, such as figuring out the first value within an account if it's null, and how to deal with numbers that are used in 2 separate averages - where a year is flanked by null above and below (chose to create a field with the last number from the previous group and the first number from the next).

 

Text to columns creates new rows for the overlap, and a filter removes rows that won't be used in the Average calculations. Then another Multi Row formula tool to determine a grouping for each set of 1 through n on the column field. 

Summarize creates the average calculations. That's joined back to the original dataset, and a formula tool replaces nulls in the Year column with the appropriate average value.

Let me know if that helps you.

 

Cheers!

Esther

bwat2435
7 - Meteor

Esther thank you so much!!! I was stuck on this for hours.

 

Have a great day

Usamah22
8 - Asteroid

Hello,

 

I am trying to do some calculations on data that looks like below. I want to take the average of the latest 2 days of sales and compare it to the average of the previous 5 days. Trying to use a multi row formula. Can you help please?

 

DateSales
28/02/20209
29/02/20208
01/03/202010
02/03/20208
03/03/20209
04/03/202015
05/03/202022
06/03/202020
Labels