473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can I generate a random number of sales this way?

Okay, so I'm back with another conundrum I hope you all can help me with.

I am trying to generate a random number of units sold (for a single sale) that is equal to a randomly generated percentage multiplied by (total purchases - total previous sales).

The problem is that I can't sum the previous sales if I am trying to generate these numbers in one query.

So I guess my question is: Will this process be able to be completed using Access?

To better understand it goes like this:

For Sale 1, it should generate a random number based on the %*total purchases. So:
Sale 1 = (total purchases)*%
Sale 2 = (total purchases - sale 1)*%
Sale 3 = (total purchaes - (sale 1 + sale 2))*%

% is just the percentage of inventory that i want the company to sell.
Dec 30 '11 #1
6 1673
NeoPa
32,556 Expert Mod 16PB
You mention "Random" in the question but nowhere is it clear where it fits in.

How to handle reuse of random numbers in your query was fully answered in your other thread. Why are you asking what is essentially the same question after indicating you were already happy you had an answer? I'm thoroughly confused.
Dec 30 '11 #2
Well the difference in the first question and this one is the formula portion. The problem is not with the random numbers this time, but rather with being able to multiply that number by the (total purchases - total sales) that occurred before the given sale date.

I've been using a query to generate the random numbers, so that means the totals for the sales before that date would be generated at the same time as the number for that date. So if I try to run an append query, it would first generate the numbers and then append them to the sales table - which wouldn't take into account the sales that occurred before a given date
Dec 30 '11 #3
NeoPa
32,556 Expert Mod 16PB
I still see no question that makes sense here I'm afraid. Even if you're happy to describe a value as random that is already available in a field within a record of a table, that still doesn't help the question to make any sense.
Dec 30 '11 #4
I totally understand why its difficult to see the sense of the question - especially given that I'm not really sure what the technical aspects of it are. I've abandoned this segment for now and just going to a more simplistic one.

If you notice that Sale 2 includes sale 1 as part of its formula, but these are all being generated in a query at one time. That means all of the numbers are generated at one time so it won't be possible know what sale 1 is for sale 2 - and therein lies the problem.
Sale 1 = (total purchases)*%
Sale 2 = (total purchases - sale 1)*%
Sale 3 = (total purchaes - (sale 1 + sale 2))*%

What I've done instead is just generated a set of random numbers that will end up being less than or equal to the previous purchase.

I've rationalized that in order for me to complete the formula the way I would want, I would have to code it in VBA and create a variable that would hold the values for me that I could then use in the calculation of the formula. But since I'm not a programmer it would be nearly impossible for me to learn how to do that and do it in the time frame that I am hoping for.
Dec 31 '11 #5
Stewart Ross
2,545 Expert Mod 2GB
Like NeoPa, I'm not clear what the purpose of the random numbers is in the context of sales etc. Is it some form of simulation in which you are testing randomised totals for sales against proportions of sales generated by particular products?

Anyhow, it seems to me that you'd be better off trying these kinds of 'let's see' scenarios in Excel, which is built for the task of modelling.

Something you may wish to explore in Excel (which you can't do in Access) is its ability to work backwards from an expected outcome to the value of a specified variable necessary to generate that outcome (goal-seeking). It may suit what you need better than the approach you are taking at present.

-Stewart
Dec 31 '11 #6
NeoPa
32,556 Expert Mod 16PB
It may help for me to say here, that any modelling done using the Rnd() function can only work reliably if the results of these calls are saved into a table before they are ever used in any calculations. This is because, as we saw before, any reference to such a result within the same SQL is actually a reference to the original formula (instead of the result itself) so will re-evaluate a new random number for you, which is not what you require.

Does this go some way to clarifying the situation for you?
Dec 31 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: vishal | last post by:
hi i want to generate a string which contains 5 characters and all 5 characters are randomly generated means it is not fixed that which string i will get after i execute function. so tell me...
3
by: vishal | last post by:
i want to generate a random number of a fixed length so how can i do this ?? i know some function which returns a single random character at a time but is there any built-in function which...
12
by: Sweety | last post by:
plz reply, thanks in advance. bye
4
by: fatimahtaher | last post by:
Hi, I am supposed to create a program that generates a random number and then asks the user to guess the number (1-100). The program tells the user if he guessed too high or too low. If he...
19
by: Sanchit | last post by:
I want to generate a randowm number between two numbers x and y i.e int randomNoBetween(int x, int y); Plz help Is there any such function??
2
by: Man4ish | last post by:
How to generate random number in normal distribution without using any external library. I found few methods implementing it. But all use GSL or boost. I don't want to use any third party library....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.