How to combine two ConfiForms tables of same structure in one view
Asked by Ulrik Schoth:

I would like to display the contents of two ConfiForms tables with the same structure in a combined view.

Example

* Both tables have just one field named "Type".
* Table 1 has 3 records of "A", "B", "C".
* Table 2 has 2 records of "D", "E".
* The target table shall display all 5 records in one table and with one column heading named "Type".

Although this seems to be a very simple question, I have not been able to achieve this. I'd greatly appreciate if anybody can show me a solution. Thanks.


Answers:
author: Alex Medved _ConfiForms_
body: Hi

It is indeed a quite simple task in our opinion... And the TableViewMerger is the macro to use

However, you need to be careful with ConfiForms Field macros that you have as these are used as "grouping keys"

So, you want to merge the data from different forms and in this case it would be greate to add a field that has a unique value, and that is an "id" field

Add a ConfiForms Field with field name set to id

And mark it to be used as "key"

![hide-as-key.png](https://community.atlassian.com/t5/image/serverpage/image-id/252439i7D4FE3F242E22F6F/image-dimensions/217x215?v=v2 "hide-as-key.png")

Alex

comments: author: Ulrik Schoth
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

Thanks a lot for this tip! I will use it in my merged tables in the future.

In the meantime, we found the cause of my problem (see my related comment). And now that I know how to use the Table Merger macro properly, I would say: you are right, it is indeed quite a simple and intuitive task! ?


author: Ulrik Schoth
body: Here's what I did: I wrapped two TableView macros with the TableView Merger macro. This would be intuitive in my opinion. Unfortunately, the result was not as expected.

I have tried some of the settings in the TableView Merger macro, but without success.

![result.png](https://community.atlassian.com/t5/image/serverpage/image-id/252354iA49FB2A1B7B7A293/image-size/large?v=v2&px=999 "result.png")

And just to clarify what I expected (unfortunately only obtained by editing the above image):

![expected-result.png](https://community.atlassian.com/t5/image/serverpage/image-id/252355i6DA860F5CD9BE3BC/image-size/large?v=v2&px=999 "expected-result.png")

comments: author: Ulrik Schoth
body: A colleague showed me what was wrong in my code: I just had to empty the body of the TableView macros and put the Field and Edit Controls macros *directly* into the body of the Table Merger macro.

So, instead of using this code:

![wrong-code.png](https://community.atlassian.com/t5/image/serverpage/image-id/252600i98CDE80A7E0D4C31/image-dimensions/312x377?v=v2 "wrong-code.png")

I just have to use the code below and everything works as expected:

![correct-code.png](https://community.atlassian.com/t5/image/serverpage/image-id/252601i39BA273EB60C8A9F/image-dimensions/309x291?v=v2 "correct-code.png")

Since I have always used the TableView macro in the past with field and edit control macros in its body, I would never have thought of this! I was not even aware that you could use the TableView macro with an empty body. ????


author: Alex Medved _ConfiForms_
body: Yes, but this way it will aggregate by "type" field - meaning that a record with the same value in the "type" field will be "skipped", counted, but skipped

You will see only the unique results by "type"


author: Ulrik Schoth
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

do you mean that if the table values are as follows

![tables-1-and-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/252674i6A1F44517F9CA998/image-dimensions/240x280?v=v2 "tables-1-and-2.png")

this solution

![correct-code.png](https://community.atlassian.com/t5/image/serverpage/image-id/252675i26121B2058579887/image-dimensions/259x244?v=v2 "correct-code.png")

should result in a table like so

![table-A-B-C-E.png](https://community.atlassian.com/t5/image/serverpage/image-id/252679i73A8AD1CC774A78E/image-dimensions/261x175?v=v2 "table-A-B-C-E.png")

because the second record with "B" will be skipped?


author: Ulrik Schoth
body: At least in my test environment this is not the case. The displayed table looks like this:

![result-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/252685i8E9A3926A863F4C8/image-dimensions/259x202?v=v2 "result-1.png")

Only when I add a field macro with fieldName=Count:(\[count\]), the second record with "B" is not displayed anymore, because both "B" records are aggregated (I just wonder where the Edit Controls have gone in this table).

![result-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/252687i5E5D2BB6CB35CE8D/image-dimensions/268x144?v=v2 "result-2.png")

And if I add an additional field "id" as you suggested in your answer above, the result looks like this:

![result-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/252688i4893658225FD17DB/image-dimensions/284x221?v=v2 "result-3.png")

In all three cases, the result seems comprehensible to me and we can gladly close this topic. ??


author: Alex Medved _ConfiForms_
body: Edit is not possible when you aggregate data - as... what will record you will edit in that case?

That is why the edit controls are gone on aggregated views

Alex


author: Ulrik Schoth
body: You are, of course, absolutely right! I had not thought of that. Thanks for your explanation!

Ulrik


author: Markisio
body: hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) and [@Ulrik Schoth](/t5/user/viewprofilepage/user-id/2108520)

curious if we can somehow identify where the data is from, ie form1 and form2, is there a solution for that?

Type, Form

A, Form1

B, Form2

....

thanks


author: Alex Medved _ConfiForms_
body: In TableViewMerger ConfiForms creates virtual fields like this

* _sourcePage - of type page
* _sourceForm - of type text

Alex


author: Markisio
body: thanks [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) !!!


author: Dhiraj Kr_ Gupta
body: Any chance of side merger like if table 1 is A, B, C and table D, E, F

A D

B. E

C. F


author: Alex Medved _ConfiForms_
body: How should ConfiForms know that A belongs to D, and etc? Do they share a "common key"?


author: Dhiraj Kr_ Gupta
body: Yes


Tags: confiforms

confluence-server

server