I’ve used the date difference column (Glide table) Start date: a Date only column, End date= now, to calculate the age of a user’s kids, with one decimal precision in years (“év” on the screenshot). If a user has more kids, I want to show the age of all kids. When I make an array, the age loses its format. What could I do?
Is it just two kids? You could create two template columns that “lock in” those numeric values by converting them to text. Then use the template columns to form your array.
Or you could use a single template column to both join, and “lock in”, both ages with a comma separating them. Then use a Split Text column to create the array from the template column.
If there’s an unknown number of kids, maybe a JS function to round each element in the array to 2 decimals and then append “év” to it, then join those together into a single string.
Thanks a lot Jeff
Each user can add up to 3 kids, I want to show the name and age of all kids on a user’s profile. The template is a good idea, it works when all name and age columns are filled, not sure how to proceed when Kid2 Name and Kid2 Age are empty for example.
Oh, I had it set up wrongly for some reason ( I think I used the logged-in user’s profile data for the template) now it works, I just need to figure out how to handle the separators (comma) between data when the column is empty.
Hehe, well…you could use a Make Array column to join the values, followed by a Joined List column to merge that array into a single text string…but I guess that puts us back to your original problem.
You could use a javascript column but you are limited to 3 parameters, so you would still need to use templates to merge values before using a javascript column.
I think you need 3 template columns to first “lock in” those ages and convert them to text. Then create a Make Array column to merge everything together. Finally create a Joined List column to convert the array to a text string.
Ah… Still, the comma problem exists with the multiple templates solution, when the kid 2 template column is empty. If I try Javascript, how could I do that?
Anyway, thanks, if nothing else, I’ll apply a more basic solution, ask for the users to input the kid’s age directly, this way it’s a number and keeps the format…
Did you try what I suggested? I think it should work. Each if the 3 template columns should only contain the age of each kid, because we first want to only convert the age to to text. Then the Make Array will merge the 3 names with the 3 age templates. Any columns that are empty should be ignored and not included in the array. Finally a Joined List should take only what’s in the array and convert it to text with commas.
I could be wrong, but I want to make sure you at least tried it.
I did try it, it works as you described, the only problem is, that where there is only 1 kid, there is an empty space separated by commas:) So it ignores in a way the empty columns, there is no text, but it’s a space separated by commas. I tried to play a bit with the separation technique, so I don’t use commas, but it’s not user-friendly.
Like @Eric_Penn said, I’m assuming that you have completely empty columns so the Make Array should be ignoring them. That’s apparent in your first post where you show the use of Make Array and the first row only has one element while the second row has 2 elements in the array. Somewhere in one of your columns, you might have an extra space that you are missing. Or there is still a misunderstanding somewhere.
It would be really helpful to see some screenshots of what you have so far.
Here is how I implemented it, is there anything that I should do differently? Kid 1 template items are separated with a comma, in Kid 2 template I did not use a comma.
That’s the problem. You are making a template with name AND age. That template introduces a space into the mix. My suggestion was to have a template for age ONLY. Make Array should be merging six columns. Not three.