Alteryx Designer Desktop Discussions

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

Sum rows and split values into separate columns based on a threshold

jamjar
5 - Atom

Hi everyone,

 

Hoping someone can help me with a challenge...

 

I've got daily quantity data (Monday - Sunday) that's grouped by a location key and then a sub-category. For example:

 

KeyCategoryMonTue...
1A26 
1B53 
1C31 
2D53 
2E43 
2F62 
...    

 

My goal is to identify when the total daily quantity for a given location key exceeds a threshold value. Then split the quantity into 'base' and 'extra' buckets.

 

For example, using the data above and a threshold of 8. For location key 1, the total across categories A, B and C for Monday is 10. So the base values would be A=2 (as 2 <=8), B=5, (as 2+5<=8) and C=1 (as this brings the base total to the threshold). The extra values would then be equal to [Mon] - [Mon_Base]. 

 

The example output would look like this: 

 

KeyCategoryMonTue...Mon_BaseTue_Base...Mon_ExtraTue_Extra...
1A26 26 00 
1B53 52 01 
1C31 10 21 
2D53 53 00 
2E43 33 10 
2F62 02 60 
...          

 

Thanks in advance!

2 REPLIES 2
Qiu
21 - Polaris
21 - Polaris

@jamjar 
Can you check if this works for you.

But there is a limitation that if the thread hold is quite large, and cannot accomendate by Base and Extra, then it will not work.

0714-jamjar.PNG

jamjar
5 - Atom

Love your work!

 

One very small edit required to the multirow formula to account for situations where the first category for the location key was greater than the threshold. The bolded bit below was referencing the Row-1 ThreadHold (which for the 1st category/row was treated as 0 rather than 8)

 

Updated formula I used:

if [RunTot_Value]<= [ThreadHold] then [Value] else if [Row-1:ThreadHold]-[Row-1:RunTot_Value]>=0 then [ThreadHold]-[Row-1:RunTot_Value] else 0 endif endif

Labels