Alteryx Designer Desktop Discussions

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

Rounding Values to Total

thelegazy
7 - Meteor

Hi All, 

 

I've gotten some great help so far, so thank you for that!

 

I think this time I have more of a formula question rather than what tool I'd use. 

 

I have a table of the following: 

 

Product CodeGenderCountryQuantity - PromisedSize CodeRatioQuantity
Product 1MaleCanada125S.337.5
Product 1MaleCanada125M.562.5
Product 1MaleCanada125L.225

 

I want the Quantities with decimals to be rounded, but I want it to total the Quantity - Promised quantity. So, rounding up would push the total quantity for Product 1 - Gender - Country - would exceed the 125 units "Quantity - Promised". 

 

There's a cumbersome process right now in Excel, but I was wondering if anyone had any guidance on how to approach this. 

6 REPLIES 6
JoshKushner
12 - Quasar
How are you getting fractional quantities? Could there be a fix earlier in your flow to give you whole quantities?
thelegazy
7 - Meteor
jdunkerley79
ACE Emeritus
ACE Emeritus

I suggest the following:

 

- Allocate a 'base quantity' equal to the Floor of the Quantity

- All will now be within 1 of the target quantity

- Compute the residual

- Filter down to just those, not at the exact quantity

- Of those you 'pick' however many you need and add 1 to them

 

The picking is where it gets interesting. I have used 3 methods in the past:

- Random

- Largest Percentage difference

- Largest Decimal difference.

 

The attached does the random allocation. If you need another approach happy to help

 

 

 

thelegazy
7 - Meteor

*Correction, I made a data entry error. Let me retry and see where I end up, sorry about that.

 

Hey, 

 

Thanks for the help. 

 

However, when I try to apply the solution I get duplicates in my data set. 

 

Also, when I try to add another product in the data set in the example provided it gives me back a number larger than the Quantity Promised for that Product - Country combination. 

 

I've attached the example. Thanks!!

jdunkerley79
ACE Emeritus
ACE Emeritus

I wasnt recomputing the Quantity at the start

 

I have added this

 

I have also added the other two picking methods (Largest Decimal Diff, Largest Percentage Diff) 

 

New version attached

thelegazy
7 - Meteor

Thanks for the update, I didn't get a chance to look at it till today. Thanks!

Labels