473,387 Members | 1,790 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,387 software developers and data experts.

Find Percentage difference among fields in a record

Nathan H
104 100+
I am trying to write a query that will result in showing records that have a large percentage difference among fields in a table.

For instance:

Table
field1.Item
field2.account1 (percentage)
field3.account2 (percentage)
field4.account3 (percentage)
etc...

An example of what I would like the result to be is this: show me the records where one account has a 20% advantage over the next highest account.

I do not know if I am approaching the problem in the right manner having the percentages all in one table.

Thanks for any help
Feb 1 '08 #1
8 3027
Nathan H
104 100+
Anybody have any ideas? Kind of an urgent matter
Feb 2 '08 #2
NeoPa
32,556 Expert Mod 16PB
I'm sorry Nathan, but I can't follow what you mean with your data so I don't get the question :(
Feb 2 '08 #3
Nathan H
104 100+
NeoPa,

Okay, I will try to clarify. I have a table that lists products by item number, and then the accounts that the particular items were sold in. The value that is showing in the account fields are a percentage of total sales for all accounts. So for instance I have Product 1, and it sold 20% into account 1, 30% into account 2, 25% into account 3, and 25% into account 4.

Table
field1.Item
field2.account1 (percentage)
field3.account2 (percentage)
field4.account3 (percentage)
etc...

This table has around 10,000 records.

What I want to do is see where there is a large discrepancy in percentage between accounts

I am trying to write a query that will result in showing records that have a large percentage difference among fields in a table, as in "show records where an account's market share is 20% higher than it's nearest competitor" by product.
Feb 3 '08 #4
NeoPa
32,556 Expert Mod 16PB
I think I'm getting you now Nathan.
You mean the .Name of field 1 is "Item" right? And you store the percentage values (for each item) for all your accounts in a single record?

Firstly, if this is the case I would recommend that you take a look at Mary's Normalisation and Table structures article. Doing it the way you seem to be is HIGHLY not recommended.

However, if you feel you have reasons that convince you that you want to persist with this type of design, let me know and I will help to put some SQL together to highlight the records you need. All assuming I'm reading you right in the first place, of course.

PS. Congratulations on reaching 100 posts. I remember when I did and it felt like a real achievement.
Feb 3 '08 #5
Nathan H
104 100+
NeoPa,

I come by the figures in a select query (to get the percentages). I would much rather work off of that. I made a table because I was experimenting with a bunch of different functions trying to find something that worked. I will not use the "make a table" function and go back to the query.

In the query I have a "TOTALS" field, which combines all the unit sales for each account, and then each account is then divided by the total to get the percentage. Very simple math I know.

So working of this, do you have some suggestions?

I hope I am not making this more confusing.
Feb 3 '08 #6
NeoPa
32,556 Expert Mod 16PB
...
I hope I am not making this more confusing.
I'm afraid you are to a degree. I appreciate your further explanation but regret the lack of direct answers to my questions.

You introduce the idea of a query that produces these results, without mentioning that it's a cross-tab query. I'm guessing that, but the fact that you don't mention it leads me to be unsure. Who would leave out something so important from an explanation if it were the case - yet I can't see any other way to understand what you're saying. It's hard to proceed without understanding the problem you see.

To find a way to approach this problem, I must understand the details of the problem. If I explain where I'm coming from you may understand why I ask the questions I do, though really why you would need to understand that before answering them is a moot point.

I need to know what the set of the accounts is. If it's a finite set then we can look at putting in explicit checks in the SQL. If it's an undefined set (there may be many or only a few) then we need to look at taking a step backwards and dealing with the data at an earlier level. In other words process the records that deal with an Item / Account - before it's grouped together to form data for the Item as a whole. You say that you produce the data from a query that joins the data into a recordset. With access to the underlying data we would want to look at comparing the Min() and Max() Accounts for an Item and seeing if the criteria you're looking for are met.
Feb 3 '08 #7
Nathan H
104 100+
I have a Master Product Table that lists products I sell (with an item number).

I get a sales report from 10 accounts each week. Each distinct report lists the item number and quantity sold of each product.

I combine the Master Product Table and the 10 account reports in a select query so that I have a record that lists the item number, and then a separate field for each account showing quantity.

Then I convert the quantity fields to show percentages by dividing by the total sales of each product.

So I am left with query results that show in this order:

Item Number
% of Sales to Account 1
% of Sales to Account 2
% of Sales to Account 3
etc...

Again, what I want to be able to do is show only the records where there is a certain percentage difference between the highest account percentage and the SECOND highest.
Feb 4 '08 #8
NeoPa
32,556 Expert Mod 16PB
In that case (having ten accounts) I would look at taking a step back and producing a (sub)query that shows the item and just one of the account's percentages. That way you would have ten records for each item.
Expand|Select|Wrap|Line Numbers
  1. subItemAcnt
  2. Item; String
  3. AccountID; Numeric or String
  4. Percentage; Numeric
From this you would produce a query comparing the Max() & the Min() Percentage across the range.
Expand|Select|Wrap|Line Numbers
  1. SELECT Item
  2. FROM [subItemAcnt]
  3. WHERE ((Max([Percentage])-Min([Percentage]))>=25)
Feb 4 '08 #9

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

Similar topics

6
by: deko | last post by:
Is there a difference between the Form_Open and Form_Load events? When should I use one rather than the other? I have several forms that require code to run when they open... or is it when they...
3
by: Ray | last post by:
I had a query of table and achived it as a table a week's ago. Now I need to find out if there are any modifications on the records against the achived table. The modification might be one or...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
ollyb303
by: ollyb303 | last post by:
Hello, Trying to help a friend/colleague out with a database and we've both drawn a blank. Not even sure if this is possible. The database has a table (Table1) with a several columns: ID,...
5
by: Aswanth | last post by:
I'm Using Asp.Net with C# & Working with SSRS 2005 for Generating Reports.. The Following Expression I'm using in Reports to Show the Percentage of Particular Items in REPORT.. ...
4
kcdoell
by: kcdoell | last post by:
Hello: I have the following afterupdate event: Private Sub GWP_AfterUpdate() 'Updates the Total calculation in the control "SumGWP" on the quick reference 'table that is located on the form...
4
by: zoeb | last post by:
Hi. I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.