Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

A value that there is a 10% chance of loss

nataliad18
8 - Asteroid

Hi!

I have a column of different values, for each of those values there is a 10% *chance* of loss from that value. Is there any smarter way to calculate total, and not just value*0.9?

3 REPLIES 3
DataNath
17 - Castor
17 - Castor

Hey @nataliad18, are you able to give a bit more detail of what exactly you mean by 'of loss'? Is it that there's a 10% chance of losing the entire value i.e. 10% chance it = 0? Or a 10% chance it loses X%?

nataliad18
8 - Asteroid

Yes - apologies, that was extremely unclear. 

So the value in a column is amount of customers and the value of loss is that there is a 10% chance that each of those customers will not be out customer anymore. i.e if there are 120 customers, each one of those 120 has a 10% chance of not being our customer anymore

DataNath
17 - Castor
17 - Castor

Thanks for clarifying @nataliad18. I'm sure there's probably a sophisticated/better way to handle this in a Formula, and hopefully someone else can chime in with that. However, here's something I've built out in the meantime - this does involve blowing up data so not ideal if you have several records with very large amounts of customers etc.

 

We start off by assigning a RecordID that we'll use later to group and Sum on:

 

DataNath_0-1679521157228.png

 

We then generate N rows where N is the number of Customers (or whatever the field is in your true data):

 

DataNath_1-1679521190031.png

 

Using the RandInt() function, we can generate an integer between 0 and x (9 here as we want a 10% chance). We then tell Alteryx that if this number between 0-9 is 1, assign it a value of 0, otherwise let it equal 1:

 

DataNath_2-1679521348002.png

 

In our penultimate step, we can group by RecordID and then Sum this new randomised field we just created. As records will be assigned 0 10% of the time, they'll essentially be 'dropped' in the aggregation:

 

DataNath_3-1679521412594.png

 

Finally, because I'm using a new version of Alteryx, AMP is the default engine and throws things out of order sometimes. Therefore, I just sorted on RecordID ascending in order to restore the original order:

 

DataNath_4-1679521463072.png

 

As the integer in the randomising step is generated upon running the workflow, you'll get varying results each time and should be a bit more dynamic/realistic than a hard-coded *0.9 value:

 

DataNath_5-1679521508422.pngDataNath_6-1679521517014.png

 

Hope this helps in the meantime. Like I mentioned before, I'd imagine there's an equation that can be replicated in the Formula tool to mimic something along these lines!

Labels
Top Solution Authors