سؤال

I've done my research, spent hours on tutorials but couldn't find an easy to understand way to create what I need.

I'm new to Access but so eager to learn. I do tons of reports on Excel but tired of how slow it can be when too much data on my data sheet. So I shifted to Access.

I have 3 Excel files with one table in each.

1° 1st excel table has a list of campaign name and tracking codes that goes with it.
"Campaign-TrackCode"(exported from a software)
ex:
Country          Campaign name                     Track Code
US                  Campaign name 1                  us-ad-1-1
US                  Campaign name 1                  us-ad-2-1
US                  Campaign name 2                  us-ad-1-2
US                  Campaign name 2                  us-ad-2-2
US                  Campaign name 2                  us-ad-3-2
etc...

2° 2nd excel table has dates; registration ID and from which tracking code "Registrations"(exported from a software)
ex:
Date                Reg ID                                Track Code
01.01.2013     1021                                     us-ad-1-1
01.01.2013     1022                                     us-ad-1-1
01.01.2013     1023                                     us-ad-1-2
01.02.2013     1024                                     us-ad-4-2
01.02.2013     1025                                     us-ad-2-1
etc...

3° 3rd excel table is a report with dates, number of clicks, campaign name. "ggle Report"(exported from a ggle ads)
ex:
Date                            Campaign name                   Clicks
01.01.2013                  Campaign name 1                  12
01.01.2013                  Campaign name 1                  46
01.01.2013                  Campaign name 2                  16
01.02.2013                  Campaign name 2                  35
01.02.2013                  Campaign name 2                  23
etc...

And I'm trying to merge my 2nd and 3rd table together via the 1st one to get a table like this in Access:
Date                    Country              Campaign name           Count RegID          Clicks
01.01.2013          US                      Campaign name 1              21                         12
01.01.2013          US                      Campaign name 2        23                         35
01.02.2013          US                      Campaign name 1        22                         46
etc...

I'm not sure what to do. I've tried the table analyzer to split my 1st table into 3 tables (countries, campaign name and track code) then connect it to my second table via track code, then the 1st table connected to the 3rd table via campaigns and then finaly use the 1st table to connect the 2nd and the 3rd.

doesn't work. Since I'm a newbee, it would be great to have a step by step to create that final table. I'm a bit lost with primary keys, and unique values. (I'm starting to get one to many relationship so I think I'm on the right path to learn). I would like not to change my excel tables since the import in access each day is almost fully automated. I download the 3 reports and then in access I append my already imported tables according to the already saved rules to import those excel files.

Would someone know how to do this?

Here is a link with examples of the tables and the output needed:

example of tables

هل كانت مفيدة؟

المحلول

Can you try running this query (changing table/field names as appropriate) and see if that's it? I'll edit this answer later when we establish this is what you wanted to achieve. ;)

SELECT 
  Table2.Date, 
  Table1.Country, 
  Table1.[Campaign name], 
  Table2.[Track Code], 
  Table2.[Reg ID], 
  Table3.Clicks
FROM 
  Table3 INNER JOIN 
  (Table2 INNER JOIN Table1 ON Table2.[Track Code] = Table1.[Track Code]) ON 
  Table3.[Campaign name] = Table1.[Campaign name]
ORDER BY Table2.Date, Table1.Country, Table1.[Campaign name];
  • Copy this example SQL query above,
  • open your Access database,
  • click on Queries tab,
  • click on New icon,
  • select Design View,
  • close the Add tables dialog,
  • click on the SQL button (top left),
  • paste this code,
  • change names as needed,
  • click on the red exclamation point (Run) icon,
  • come back with your findings...

;)

EDIT: I've added sorting at the end of the query. You can of course change the sorting order by swapping fields listed in the ORDER BY clause, add some more, omit some, and if you want them to sort in descending order, add DESC at the end of the field name, separated by a space (e.g.: ORDER BY Table2.Date DESC, Table1.Country to have records sorted first by Date in descending order, and then by Country in ascending order ASC that is a default sorting order).

I also suggest you have a look at the built-in query builder (Design View) after you're done editing the SQL syntax. You'll find it's rather useful to build your own queries fast. Copied SQL clause will give you a nice example in how tables are related one to another in the WYSIWYG query builder. You can of course also change all the relations, sorting orders, display orders,... by simply moving things around. ;)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top