Use column header name in expressions

Hello guys

Is there a way to use the column header name inside of an expression? I want to make like a matrix table to use it for the show If option. I have too many types and all the columns must behave different depending on the selected type.

There may be a way - can you give an example of what you are trying to achieve?

1 Like

In a form i have a column named “Type” ( list with 20-30 types ) and more than 20 columns that represent specs of the chosen type. Some of the columns doesn’t apply for some types and i want to hide them.

Instead of writing a long expression that can cover all types i want to make a table with 3 columns ([Column Name] , [Type] ,[Show?] ) and apply a standard expression ( find or select ) that wll return if it needs to be hidden or not. In this case i need to use the column name in the expression otherwise i’ll need to manually write it for each expression, in each column.

Does make any sense?

Hi @Bogdan_Stan , Yes, that makes sense- but it’s not possible in AppSheet. Here are a few related feature requests.

2 Likes

Hey @Bogdan_Stan
While you can’t natively call the column name, you can certainly “hard-code” it into your proposed formula; then the only thing that would need to change in the formula is the individual column name.

I’ve done things like this before;

and while it can be a pain to go through EVERY column that’s shown and apply a show-if (each requiring a quick copy/paste data change), it doesn’t really take that long - and you only have to do it once.

  • Ultimately, you’d have to copy a formula into each column’s show if anyways… this process only adds 1 or 2 steps to each.

For example:

Let’s say I’ve got a “Configuration” table (with a sleight modification to what you’re proposing):

  • [Column_Name] - contains the text value of each column name
  • [Visible_Types] - an EnumList containing all the types that should show the field

My show_if formula would look like this:

IN([Selected_Type], 
  LOOKUP("Column_Name", 
    Configuration, Column_Name, Visible_Types
  )
)
  • The only thing that needs changing is the value inside the “double quotes” stating the column name to pull
    • So the workflow for this would be the following
      1. Open the show if for a column & Paste your template formula
      2. Copy the name of the column (from the top label of the expression builder) & Paste it into the hard-coded space
      3. Save

You can get real fun and automate most of this utilizing a macro recorder.

  • You can record the following steps with a PC-based macro recorder:
    • Paste the template formula
    • copy/paste the column name
    • save

Then you simply need to replay these after you open each column’s show if, and all the “work” is done for you in a flash. Then it’s only a matter of “processing” through each of your column’s show-if fields.

1 Like