Making and Exploring Crime Networks (Access and Excel) (2024)

I’ve been doing quite a bit of stuff with gang networks lately at work. Networks are a total PIA though to create and do data manipulation on in traditional spreadsheets and statistic tools, so I figured I would blog about some of my attempts to ease the pain for fellow crime analysts.

First I will show how to create an edge list in Access from the way a traditional police RMS database is set up. Second I will show a trick about exploring people and gangs by creating a dynamic lookup in Excel. You can download the Access Database I used and the Excel spreadsheet here to follow along.

Making an Edge List in Access

I’ve previously shown how to make an edgelist in SPSS. I’ll cast the net wider and show how to do this in Access though.

In a nutshell, an edge list is a table of the form:

Person A, Person BPerson B, Person CPerson C, Person D

Where being in the same row shows some type of connection between the two persons, e.g. Person A is connected to Person B. In police databases the connections most often of interest are co-offending (e.g. two people were arrested for the same incident) or being stopped together (e.g. in the same car or during the same field interrogation).

Typically police databases will have a table that lists a common incident identifier, along with persons associated with that incident and their involvement. Here is a screen shot of the simple example I made in an Access Database to mimic this which I named IncidentPersons:

Making and Exploring Crime Networks (Access and Excel) (1)

So here we can see that for incident 1, Andy Pandy, Sandy Randy, and Candy Dandy are all persons involved. Candy is the victim, and the other two were arrested. This table is always called something different for every PD’s RMS system, but some examples I have come across are crossref and person_exploded. All RMS’s I have seen though have some sort of table like this.

To make an edge list from this table takes some knowledge of SQL, but it can be done in one query. Basically we will be joining a table to itself, and selecting out distinct rows. Here is the most basic SQL query in Access to accomplish this.

SELECT DISTINCT F.PersonID, F.PersonName, S.PersonID, S.PersonNameFROM IncidentPersons AS F INNER JOIN IncidentPersons AS S ON F.IncidentID = S.IncidentIDWHERE F.PersonID < S.PersonID;

To walk through this, we make two table aliases from the same original IncidentPersons table, F and S. Then we do an INNER JOIN based on the original incident ID. If we stopped here without the last WHERE clase, what would happen is we would have pairs of people with themselves, and with duplicate ties of the form A -> B and B -> A. So selecting only instances in which F.PersonID < S.PersonID eliminates those self edges and duplicates. The last part here is SELECT DISTINCT instead of select. This will make it so any particular edge is only returned once. (If you deleted DISTINCT in this database, Andy Pandy -> Sandy Randy would be returned twice.)

Running this query we then have:

Making and Exploring Crime Networks (Access and Excel) (2)

In practice it will be more complicated because you will want to filter certain connections and add more info. on people into the final edge list. Here I ignore the involvement type, but you may want to only restrict matches to certain co-involvements (since offender-victim is of a different nature than co-offending). You also may want to not just know those connected, but count up the number of times those people are connected. For my work, I have always just limited to co-offending and being stopped together (and haven’t ever worried about the number of ties).

Also depending on how the database is normalized, often people names will change/have spelling errors, but they will still be linked to the same personid. These different spellings would cause the DISTINCT selection to not work as expected. A workaround is to only select based on the unique PersonID’s and not import other data, then in an additoional query merge in the person data. For gang network analysis you will likely want to merge in gang affiliation (which will probably be in a seperate table, not in the RMS). If you are still following along though you can figure that stuff out on your own.

Making an Edge Lookup Table in Excel

So now that I have shown how to make the edge table, what to do with it now? (No excuses – since I gave examples in both SPSS and SQL!) Here I will show a simple trick to explore the network using filtering in Excel.

The edge list itself is often the needed format to import into other network based software. So you can make a nice network graph using Gephi or whatever. The graph is good to see the overall form of the network when the graph is limited to only a few nodes, but they are typically really complicated, and tools like Gephi aren’t very good for drilling down into specific people. Here I will show my simple drilldown solution using Excel.

The network I use for this example is entirely made up; it was simulated using NetworkX (python), names are random based on some internet lists of popular baby names and last names I forgot the source of already, and Date of births are random between 1975 and 1997. I also made up a list of 7 gangs (but people have a 9/16 chance to be assigned to no gang).

So starting with an edgelist, here is a screenshot of my made up edge list excel table.

Making and Exploring Crime Networks (Access and Excel) (3)

The problem in this format is if I filter the Id.1 column for 19 (BONNIE BARKER), they could potentially be in the Id.2 column as well, so I potentially miss edges. A simple solution to this is just to duplicate the data, but switch the order of the edges. Then when I filter by Id = 19, I will get all possible Bonnie Barker edges.

For a simple example of how to do this on a small table, if you start with:

17,1918,1919,2019,21

If you filter the first column by 19, you will eliminate the 19’s in the second column. So just make a new table that has the ID’s reversed:

19,1719,1820,1921,19

And then stack the two tables on top of one another

17,19 |18,19 | Table 119,20 |19,21 |19,17 +19,18 + Table 220,19 +21,19 +

So now if you filter the first column by 19 you get 19’s all four connections. This is just three copy-pastes in excel to go from the original edge list to this table.

Now we can make a filter that dynamically changes based on user input. Here I make a selection in the top row, in N2 you can put in a persons ID. Then in A2, the formula is =IF(B2=$N$1,1,0). You can then paste this formula down, and it always references cell N2 because of the absolute $ modifiers.

Here is a screenshot of my example LookupTable in excel filtering for person 431.

Making and Exploring Crime Networks (Access and Excel) (4)

If you update the personid in N1, then hit the reapply button in the toolbar (or hit Ctrl+Alt+L) to update the filter. Here I updated to be person 382.

Making and Exploring Crime Networks (Access and Excel) (5)

The context of why I created this example was to identify people that were connected to gang members, but themselves were not in the gang. Basically have a list to take to officers and say, are you sure this person is not an actual member of the gang? The spreadsheet is then a tool if I have a meeting, where someone can say, who is Raelyn Hatfield connected to? I can easily update the id and filter.

You can do this drill down in the original edge table if you have the IF condition look in both the first and second id column, but I do this because it is easier to see who a person is connected to. You only have to look in one column – you don’t have to scan back and forth between two columns to see the connections.

You can also do other aggregations on this table as well. For instance if you aggregate using a pivot table and count the number of instances it is the edge centrality of a person (i.e. the number of different people a person is connected to).

If you want to do a drilldown of specific gangs you could use the same logic and build another filter column, but this will duplicate people when they are connected to another person in the same gang. That would be an instance where it might be easier to use just the original edge table.

Making and Exploring Crime Networks (Access and Excel) (2024)

FAQs

How do you link Excel and Access? ›

If you're using the latest version of the Microsoft 365 , Access 2021, or Access 2019, on the External Data tab, in the Import & Link group, click New Data Source > From File > Excel. If you're using Access 2016, on the External Data tab, in the Import & Link group, click Excel.

Is Access or Excel a database? ›

They are two different tools. Access is a database, used for manipulation of data. Excel is a spreadsheet used for numerical analysis. There is a lot that both can do, but they each have their own specialist areas.

What can you do with the data that you import from an Excel workbook into Access? ›

A good way to get started is to copy data from Excel into Access. You can create an Access table and display it in datasheet view, which closely resembles an Excel worksheet. You can do common table creation tasks, such as defining a data type, a field name, or a new field, right in the datasheet view.

How can Excel be used as a database? ›

How to Create a Database in Excel
  1. Step 1: Set up a data spreadsheet framework. Open an Excel spreadsheet, place your cursor in the A1 cell, and type in your database title. ...
  2. Step 2: Add or import data. ...
  3. Step 3: Convert your data into a table. ...
  4. Step 4: Format the table. ...
  5. Step 5: Save your database spreadsheet.
Apr 2, 2024

What is the best way to use Access and Excel data together? ›

Create a data connection between Excel and Access
  1. Go to the Data tab in Excel and click the From Access button.
  2. On the Select Data Source dialog, go to the location where the Access database is stored, select it, and click the Open button.
  3. On the Select Table dialog, choose a table from the database to import.
Aug 14, 2012

How to create an Access database from Excel? ›

Import data from Excel
  1. Open the Excel workbook, make sure each column has a heading and a consistent data type, and then select the range of data.
  2. Select External Data > New Data Source > From File > Excel.
  3. Select Browse to find the Excel file, accept the default values, and then click OK.

Is Access harder than Excel? ›

Excel is easy to create dashboards and formulas, whereas Access is easy for databases and connections. For example, the Excel and Access worksheets are shown in the images below. The logos of Excel and Access are shown below.

What is Access used for? ›

Microsoft Access enables business and enterprise users to manage data and analyze vast amounts of information efficiently. The program provides a blend of database functionality and programming capabilities for creating easy-to-navigate forms.

How to manage Access in Excel? ›

Restrict permission to content in files
  1. Save the workbook.
  2. Select File > Info.
  3. Select Protect Workbook, point to Restrict Permission by People, and then select Restricted Access.
  4. In the Permissions dialog box, select Restrict permission to this workbook, and then assign the access levels that you want for each user.

What is a primary key in Access? ›

A primary key is a field or set of fields with values that are unique throughout a table. Values of the key can be used to refer to entire records, because each record has a different value for the key. Each table can only have one primary key.

Can an Excel file be converted to Access? ›

Step 1: Import data from Excel to Access. Importing data is an operation that can go a lot more smoothly if you take some time to prepare and clean your data. Importing data is like moving to a new home. If you clean out and organize your possessions before you move, settling into your new home is much easier.

How to create relationships in Access? ›

On the Database Tools tab, in the Relationships group, click Relationships. On the Relationships Design tab, in the Relationships group, click Add Tables. Select one or more tables or queries and then click Add. After you have finished adding tables and queries to the Relationships document tab, click Close.

How do I give Access to an Excel link? ›

Share your workbook
  1. Select Share.
  2. Set permissions. Allow editing is automatically checked. Uncheck this if you only want to give permission to view the file, not edit it. ...
  3. Enter the names or email addresses of who to share with.
  4. Add a message (optional).
  5. Select Send. Or, select Copy link to get a link to the file.

Can Excel pull from Access? ›

Microsoft Excel includes a command to import data from an Access database. You can use that command instead of the export command in Access; however, the Excel import command only allows you to import tables or queries. For more information, see the Excel Help article Connect to (import) external data.

How to merge Excel files into Access? ›

Import or Link to the Excel file:
  1. In Access, go to the External Data ribbon (i.e. toolbar tab).
  2. Select the Import Access Database icon.
  3. Follow the import wizard steps. Linking to the Excel file creates a link "table" in Access.
Jun 27, 2018

How do I link a database to Excel? ›

In Excel, on the Data tab, in the Get External Data group, click From Other Sources, and then select From SQL Server. The Data Connection Wizard opens. On the Connect to Database Server page, in the Server name box, specify the name of the server where the SQL Server data that you want to use resides.

Top Articles
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated:

Views: 6006

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.