Alteryx Designer Desktop Discussions

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

Adjust denominator for average calculation dynamically

jaimonsk
8 - Asteroid

Hi Team,

Let's say there is a dataset for sales of cars for a year (Monthwise) as shown below. The idea is to generate Average column dynamically. The Average column needs to be found in such a way that if there are 2 or more than 2 months have no sale, then that month needs to considered as inactive. Therefore while counting the delimiter on taking average, we need to discard the inactive months. Ex: In row 1 the denominator is 10. Can someone help me with this logic?

 

Car2018-12018-22018-32018-42018-52018-62018-72018-82018-92018-102018-112018-12Average
X0010203010304020505021.5
Y100001056005007.2
Z0000000000201015
A00013000000000130
B00000000001507.5
6 REPLIES 6
mceleavey
17 - Castor
17 - Castor

@jaimonsk ,

 

I assume you meant 9 for row 1, not 10.

 

I built this using a bit of transpose and crosstab magic:

 

mceleavey_0-1623756200380.png

 

mceleavey_1-1623756232907.png

 

Hope this helps,

 

M.

 



Bulien

danilang
19 - Altair
19 - Altair

hi @jaimonsk 

 

There's no single function to do this, since you have the 2-or-more criteria, but you can calculate this yourself

 

danilang_0-1623756388474.png

 

Transpose the values and use a multi-row tool to look for consecutive 0's.  Mark those rows with 0 and the all the rest with 1.  Sum the values and the marks and use the marks as the denominator.  

danilang_1-1623756593113.png

Dan

 

 

jaimonsk
8 - Asteroid

Hi @mceleavey , @danilang Thanks for the reply. The earlier example i attached was wrong with the criteria i mentioned. I have updated the dataset accordingly and added a <bold> for every numbers which would be in scope. So for first row and last row. The zero at the end would need to get counted in denominator selection. which would alter the average calculation done earlier.
ie, the cell would be considered inactive only if there are 2 or more than 2 continuous cells are zero. In the mentioned case the zero would then need to get counted as active..
Sorry for the confusion!

mceleavey
17 - Castor
17 - Castor

Hi @jaimonsk ,

 

I've applied that bit of scope creep 😉

 

Obviously now your averages are different as you are increasing the denominator value for the calc.

 

M.



Bulien

jaimonsk
8 - Asteroid

Superb 🙂
Thank you @mceleavey 

mceleavey
17 - Castor
17 - Castor

no problem.gif



Bulien

Labels