Hello, I am new in glide and have a free plan. I have a table that references the phone number of the embassy of each country in all the other countries. so my table has 250 columns and 250 rows, each one corresponds to a country.
It makes 2 days I am trying to find a solid way to display the number according to the citizenship country and to the destination country of the user. Should I go to paid plan or is there something to do ?
(Note: display condition “if + column is citizenship” is not working )
Thank you in advance for your hep
Here a screenshot of a part of my table :
Having a column for each country makes it very difficult to manage. Would you be willing to consider a structure more like this? You will have a lot more rows, but only 3 columns and it will make the app a lot easier to manage and query the appropriate number.
from_country | to_country | number |
---|---|---|
Algeria | Albania | 35542231158 |
Angola | Algeria | 21321392533 |
Algeria | Argentina | 21323187440 |
Angola | Argentina | 2442223232 |
Albania | Armenia | 355662054227 |
Albania | Austria | 35542274855 |
Algeria | Austria | 21324728151 |
Angola | Austria | 2442223393 |
Antigua and Barbuda | Austria | 12684638698 |
Ignore the actual data. I used AI to normalize the data, and it didn’t quite do it correctly. But hopefully you understand what I’m getting at with the table structure.
Thank you very much Jeff ! I hope to find a solution with less line though as my table will regularly change and be improved. (255*255 would be 65025 lines ).
All you need is a single table with 255 rows and 2 columns. One column for the country name, and one column for the phone number.
- Present the user with 2 choice components, one to select their country of citizenship, and one to select their destination country.
- Use your list of countries as the source of each component, and write the selections to two separate User Specific columns
- Use each of those User Specific columns to create a single relation to your Countries table, matching the country name
- Then use two lookup columns to fetch the phone numbers via the relations.
It would not be that many rows. Your matrix shows a lot of empty cells, There aren’t 255 embassies in each country I assume. You would have the same number of rows as you would the number of filled cells. There wouldn’t be a row to represent empty cells.
Your setup would require 255 conditions and 255 components. All multiplied by the number of components, conditions, columns, etc. Basically a maintenance nightmare. My suggestion would be 1 of everything instead of 255. Much easier to setup and maintain.
@Darren_Murphy I think there is a bit more to it. How many Australian embassies are there around the world? They wouldn’t all have the same phone number. The way I understand it is they want the phone number for the Australian embassy located in the US for example. Not the number of the Australian embassy located in France.
oh yeah, good point.
Maybe this is a good use case for a JSON structure?
ie. One country per row, and then a JSON structure that contains the details of all embassies in that country?
Yeah, that would definitely keep the row count to a minimum. A column for the from_country and a column for the JSON containing all to_countries and phone numbers. Then it’s just a matter of querying to the correct row, retrieving the JSON, and using JSON Query to retrieve the phone number for the selected country.
I think it all depends on how that JSON is maintained.
Thank you to both of you ! Correct @Jeff_Hager it is about displaying the correct phone number, not about the number of ambassies in each country. And correct, in this table cells are empty. However I will have another table of data with all cells filled, so I would like to find the best way to iterate through all the tables the same way. I’ll try json @Darren_Murphy
What I finally did to solve that in 2 cells only using json + javascript
- I transformed my table into an INLINE json (through a simple python script), then I completely removed my table. the json looks this way (but inline) :
{
origin-country-name {
destination-country-name {
embassy-number: “0943580398”
}
},
…. repeated for all embassies in all countries
} - in a cell TEXT: I paste this json
- in a cell JAVASCRIPT I paste a javascript code to get my value dynamically
in my case :
let data = JSON.parse(p1);
let origin-country = p2.toLowerCase();
let destination-country = p3.toLowerCase();
let match = data.find(e =>
e[“in-country”].toLowerCase() === country &&
e.consulates && e.consulates[city]
);
if (match) {
return match.consulates[city].number;
}
return “”;
- select in p1 : column with json
- select in p2 : user > destination country
- select in p3: user > origin country
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.