Format Table - Align Cell Text with Appropriate Column Header
Asked by Emily Berg:

Hello Community! I am tagging [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746) as she has answered several of my previous questions.

I have a table that I would like to sort the values into the appropriate column header match. See attached input and desired output tables. Any advise is appreciated!

Emily

![2023-01-25_11-42-58.png](/t5/image/serverpage/image-id/236403iD3232663A534AFC3/image-size/large?v=v2&px=999 "2023-01-25_11-42-58.png")


Answers:
author: Emily Berg
body: Sorry for the submission, I was able to solve the problem myself using the StiltSoft [Advanced Use Case](https://docs.stiltsoft.com/tfac/dc-server/custom-transformation-use-cases-with-advanced-sql-queries-42241587.html) information.

I used the following SQL:

SELECT \*,  
CASE WHEN (MID(T1.'Text',1,6)) = "BPFAAA" THEN T1.'Text' END AS 'BPFAAA',  
CASE WHEN (MID(T1.'Text',1,6)) = "BPFBBB" THEN T1.'Text' END AS 'BPFBBB',  
CASE WHEN (MID(T1.'Text',1,6)) = "BPFCCC" THEN T1.'Text' END AS 'BPFCCC'  
FROM T1

comments: author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Emily Berg](/t5/user/viewprofilepage/user-id/2275341),  

Glad that you've found an answer yourself. Let me also suggest an option if not for this case, then for the future ones -- how to avoid using filters (here I mean "BPFAAA", "BPFBBB", etc.) in the query. It may come in handy if there are many different variants and if they are changing dynamically (for example, coming from the Jira Issues macro).  

![Thu 5-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/236694i993519F61FB21ED1/image-size/large?v=v2&px=999 "Thu 5-1.png")  

SELECT 'Filter',  
FORMATWIKI(SUM('Text' + "\\\\ ")) AS 'Text'  
FROM (SELECT 'Text'-\>split("-")-\>0 AS 'Filter',  
'Text'  
FROM T\*)  
GROUP BY 'Filter'  
Here I automatically split the first part of the 'Text' field (you do smth similar in your query) and group my data by these first parts.  

Then I also need to transpose my result table:  

![Thu 5-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/236696i74572ECCC29943BC/image-size/large?v=v2&px=999 "Thu 5-2.png")

![Thu 5-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/236697i7F8A80AEF9F33A73/image-size/large?v=v2&px=999 "Thu 5-3.png")  

And you may do the same thing using the [Table Spreadsheet](https://docs.stiltsoft.com/tfac/dc-server/how-to-use-table-spreadsheet-macro-83100938.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macro:  

=IFERROR(IF(SEARCH(B$1,$A2),$A2, " "), " ")  
Copy/paste this formula to all the table cells.  

![Thu 5-4.png](https://community.atlassian.com/t5/image/serverpage/image-id/236699i4091E7E77105C886/image-size/large?v=v2&px=999 "Thu 5-4.png")  

Unfortunately, the Table Spreadsheet macro doesn't support the Jira Issues macro as a source table. We have such feature in our roadmap, and once it is implemented, I'll get back here to notify you.  
But if your case is based on the manually created table or csv/xlsx file, then you may also use this option.


author: Alexey Mikhaylov _Stiltsoft_
body: Hello [@Emily Berg](/t5/user/viewprofilepage/user-id/4210574) ,

Let me inform you we've released a new macro - [Spreadsheet from Table](https://docs.stiltsoft.com/tfac/dc-server/how-to-use-spreadsheet-from-table-152142229.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources%20&utm_vendorID=1216111) - which allows transferring your regular table or a table outputting a macro's content (such as, for example, Page Properties Report or Jira macro) into [Table Spreadsheet](https://docs.stiltsoft.com/tfac/dc-server/how-to-use-table-spreadsheet-macro-83100938.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources%20&utm_vendorID=1216111) with all its tools. It is available starting from Table Filter and Charts for Confluence version 10.0.0.


Tags: confluence-server

filter

server

stiltsoft

table

table-filter

table-filter-and-charts

table-spreadsheet

table-transformer