Funny iteration on days of the month

nowanda

Board Regular
Joined
May 27, 2002
Messages
67
Howdy!

Funny question - If I have sales data for every day of the month - and I would like to see how many days are between sales that are greater than 100$ - how would I set this up?

Here's the table in question:
Month___________day_in_month________
_______1___2___3___4___5...___30___31
---------------------------------------------
July___75__15_115__50_125___10___67
Aug___175_35__15__50_105___38___73

So in July I had an interval of 2, 1, ... etc
And in Aug I had an interval of 0, 3, ... etc

I figure I'll need a module that goes through each field [1],[2],..[31] and checks if the value is >100. If it's >100 I'll need to compare it to the next value.. and so on..

Possible? Probable? :help:

Thanks!

Nowanda:)
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You can probably do this in a query. Can I bother you to give a better example of your table? I'm pretty confident that we can get this solved if you can do this. (Even if you just copy a few rows of the table then paste here it will be fine for me).

Thank you,

Russell
 
Upvote 0
Hooray - Russell to the Rescue :pray: !

Here's a more clear copy (thankyou Colo).. but this little lamb requires a shephard's guidance to get a query that isn't >256 characters long!!

Note that this display only includes up to the 21st. - It actually has data up to the 31st. Some of the entries are null - they can be assumed to be zero.

Thanks a zillion!

Nowanda:)
Book1
ABCDEFGHIJKLMNOPQRSTUVWX
1IDmonthyear123456789101112131415161718192021
21Apr20020009400017846504904613000001600
32May20020000023305050015036485000178000
43Jun20021580500008464000430012010015031
54Jul2002326400180002600181426002220104026044
65Aug200224261800086100280080116026460020000
Sheet1
 
Upvote 0
Man, that is one ugly table! Do you (or does someone) enter that data by hand? Just FYI, it would be much more manageable if you just entered the date and the sales amount. Then you could manipulate it in several different ways (including into a table that looks like yours). Unfortunately, the reverse is not true. I am a little busy today, so give me a while to think about this. Maybe someone else will step in before I get a chance to finish.

Sorry,

Russell

p.s. Why are you worried about 256 characters?
 
Upvote 0
Hmm...

Yup - it was all entered by hand I believe (I feel sorry for the chap that had to do that). It's possible to export it to excel without any trouble if handling it would be easier in excel.

The table is in Access 2000 - An idea I had was to create a query whose results were "binary" by letting each day =1 if the sales were greater than 100 and if not then letting the value =0. Also thought of concatenating the results all together - like so:

month year concat_result
Jan 1992 0001100000000100000000100000000
Jan 1981 0000000000000000000000000000000
Jan 1982 0000000000000000000000000000000
Jan 1973 0000000000000000000001000000000

And then maybe some sort of Do..While.. going through the concat_result one character at a time.

I suppose if the table wasn't this ugly then I wouldn't be in desperate need of Mr. Excel's message board!! :cry:



Thanks!

Nowanda:)
 
Upvote 0
What about creating a cross tab query or exporting the data to Excel and creating a Pivot Table. Wait you can also create Pivot Tables in Access.

Parra
 
Upvote 0
Well, here's what I would do. I would export the data into Excel and transform the table. Something like what I have below. Before you look below, let me tell you what I did (because the table below is not exactly like what I have - I've only included some example rows and columns). First, I put the earliest "date" that is in your table in a cell below the table. Then I dragged down to fill in all dates between that one and the last "date" (I added Jan 2003 just to make sure everything worked right even if there were skipped months, etc. I also didn't think that the ID was necessary, but I included it just in case). Then I applied the formulas included below.
Book3
ABCDEFG
1IDmonthyear1234
21Apr200200094
32May20020000
43Jun2002158050
54Jul2002326400
65Aug200224261800
76Jan200335238381
8
9fldDatefldSalesfldID
1004/01/200201
1104/02/200201
1204/03/200201
1304/04/2002941
1405/01/200202
1506/02/2002153
1606/03/2002803
1706/04/2002503
1807/01/2002324
1907/02/2002644
2008/01/2002245
2108/02/2002265
2208/03/20021805
2301/01/2003356
2401/02/2003236
ConvertData


Then I just copied the new table, went to Access, selected the Tables tab of the Database Window, and went to Edit-Paste. I clicked yes when it asked me if my data contained header rows. I then renamed my table to tbl081303.

Ok, then I wrote a query like I have below. Note that you can modify this to suit your needs:
  • SELECT X.fldDate, X.fldSales, [fldDate]-(SELECT Max(fldDate) FROM tbl081303
    WHERE tbl081303.fldSales>=100 AND tbl081303.fldDate< X.fldDate) AS DaysBetween
    FROM tbl081303 AS X
    WHERE X.fldSales>=100;
Just change tbl081103 to your table name, and the field names to your field names (if you used ones different from my Excel example). Don't change X.

This worked for me, so let me know if you have any problems executing it and we'll work it out.

HTH,

Russell

p.s. Good luck on that Pivot Table, Parra! :laugh:
 
Upvote 0
sweet holy mother of pearl!!

It actually works! I'll have to do some extra legwork because I have reams of data - but this is a good platform to jump off of!

Thanks Sensei Russell - :bow: - I guess my firsborn will need to be named R.H.!

Nowanda:)
 
Upvote 0

Forum statistics

Threads
1,223,461
Messages
6,172,372
Members
452,456
Latest member
Ktyehf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top