[SQL] How to get name of column head
Asked by huangbin chen:

Hi Experts,

I would like to achieve below table transformer:

to make a condition and get name of column head, fill the column head name into new column.

Is this possible?

![get-col-head-name.png](https://community.atlassian.com/t5/image/serverpage/image-id/339317iF33065DB00B7BE06/image-size/large?v=v2&px=999 "get-col-head-name.png")

Thanks


Answers:
author: Stiltsoft support
body: Hi [@huangbin chen](/t5/user/viewprofilepage/user-id/4921775) ,

The Table Transformer macro is provided by our app - [Table Filter, Charts \& Spreadsheets for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-charts-spreadsheets-for-confluence?tab=overview&hosting=cloud&utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111).

If I understand you right, you need not to simply transpose your table but to check in which column appears the first "TRUE" and then set this column name in a separate column.

You may try the CASE WHEN function and check each column one by one. Here is an example of a similar structure: <https://docs.stiltsoft.com/tfac/cloud/custom-transformation-use-cases-with-advanced-sql-queries-42241587.html#CustomTransformationusecaseswithadvancedSQLqueries-UsingIf/Thenconstruct>

The column names should be written in the SQL queries manually (or you can set some comments, statuses, etc.):

SELECT \*,  
CASE WHEN T1.'AAA' LIKE "TRUE" THEN "AAA"  
WHEN T1.'BBB' LIKE "TRUE" THEN "BBB"  
END  
AS 'Leading'  
FROM T1

comments: author: Stiltsoft support
body: Also what concerns the conditional formatting (how to make cells with "TRUE" green), you may check our documentation for reference as well: <https://docs.stiltsoft.com/tfac/cloud/advanced-table-cells-formatting-58426218.html#Advancedtablecellsformatting-Conditionalformatting>


author: Stiltsoft support
body: And also your screenshot has caught my eye - as your example was created in a spreadsheet (Excel or Google Sheet), maybe it will be more convenient to switch to the [Table Spreadsheet](https://docs.stiltsoft.com/tfac/cloud/how-to-use-table-spreadsheet-macro-83100938.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) (you create your original table inside the macro) or [Spreadsheet from Table](https://docs.stiltsoft.com/tfac/cloud/how-to-use-spreadsheet-from-table-macro-152142229.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macro (it turns your manually created or macro generated table into a spreadsheet automatically)?

Using cell formulas and familiar conditional formatting may be more intuitive for some cases.


author: huangbin chen
body: Thanks. Yes, seems this is the method to achieve what I want.


author: YY Brother
body: Hi [@huangbin chen](/t5/user/viewprofilepage/user-id/4921775)

Is your question about Jira issue search result? What's your specifc business scenario then?

Regards,

YY?

comments: author: huangbin chen
body: \>\>about Jira issue search result?  
about how to use SQL to add column head name.

Just try to find the first match and get the corresponding column head name, then fill to another new column.


author: YY Brother
body: Oh it's a SQL related technical question


Tags: cloud

confluence

filter

jira-cloud

table

table-filter

table-filter-and-charts

table-filter-charts-spreadsheets

table-transformer