How to insert flag icons in tables
To illustrate your table and to make it easier for readers to spot certain countries, it's possible to add little flag icons (in a square format or in format 4:3) in Tables. In this article, we'll show you how to do so.
1 Preparing the data
To insert little flag icons in your table, you need flag codes. You will recognize them because of their format: :ch: will translate into the icon of the Swiss flag and :jp: will turn into the Japanese flag.
You can find a complete list of available flag codes here.
In your data, you can place these flag codes in an extra column or in cells that already have another content (scroll to the end of this article to find extra tips for how to prepare the data in Excel). Datawrapper will replace them with the icons.
That's how the data looks like for our table up there:
2 Turning the feature on
If you upload your data in this format and go to step 3: Visualize, your table will display the flag codes instead of the flag icons. We need to turn this feature on so that Datawrapper knows that we want to see flag icons.
To do so, go to the Refine tab and select all the columns with flag codes (press Shift to select multiple columns). Once we click on "Replace country codes with flags", our flag codes will turn into flag icons:
Once activated, we can decide in which format we want to display flag icons:
Extra: How to use Excel / Google Sheets to combine country names and flag codes
Let's imagine we have a long list of countries. We don't want to type in the flag codes by hand for each of these countries. How can we automate the process?
The Excel / Google Sheet formula VLOOPKUP is our friend! That's how it works:
A Get the flag codes table. To do so, copy & paste this whole table with the flag codes into your own Google Sheet or Excel, or simply copy it.
B Bring the table in the right format. Once you have the flag codes table in your Excel/Google Sheets, you can delete the columns with the images and the last column with the continents. And you should change the order of the columns: The country name column should be left out of the flag code column.
C Add the country names you want to combine with flags. Now it's time to add your data. Maybe you have a list of country names? Place them right of the two columns you just copy and pasted from our table.
D Magic! Now it's time for our last and most important step: A formula named VLOOKUP that works both in Excel and Google Sheets: =VLOOKUP(D3,A:B,2,FALSE)&" "&D3
...if the table with flag codes and country names starts in row 1 and in column A of your spreadsheet, and
...if the name of the country you want the flag code for is in cell D3 (row 3, column D).
You might need to adjust the formula so that it works for your data.
Now copy & paste this formula with either clicking Cmd + C & Cmd + D, using the context menu in Excel Google Sheets or with applying the formula to all cells below with clicking and dragging the blue corner rectangle downwards, as shown here: