How can I get the count of the number of columns in a table?

I have a table where each column is a new entry. (It makes it easier to read rather than having each new entry be a row).

I want to know the total number of columns in this table. Is there a way to achieve this?

Probably not. This kind of introspection isn’t really enabled by the Formula language.

If you do things normally you can just use Count().

@Nick_Linck it is like @loucadufault says, but to make reading easier you can use grouping, a table option that allows you to alter the view of the table according your liking.

1 Like

Hey @Nick_Linck
I made a little pack that adds this formula to your doc.
2022-08-07 11.42.44

You need a Coda API Key when installing the pack. You can generate one in your account settings.

You have to give the formula the doc id (autocomplete will show you your docs) and the table id (autocomplete will show you the tables in the selected doc) and you will receive the number of columns. The number will be cached for 10 seconds.

You can find the pack code here:

8 Likes

The Doc Explorer pack in the Coda Gallery can do this and much more!

It can also give you column names, column formulas, it gives you pages, row count for tables, and so much more.

Give it a try

4 Likes

Forgot about your wonderful pack @Scott_Collier-Weir :clap:t4:

hi @Daniel_Stieber , just to say that I appreciate very much that you shared your code so we all can learn and improve. Merci, Cheers, Christiaan

3 Likes

Thanks everyone! I went with the doc explorer solution proposed by scott, made a new table that listed the columns and then took a count of those columns

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.