It's all about the answers!

Ask a question

how to display values in multiple rows in a single row and column?


Rini Kunchandi (1112) | asked Feb 22 '16, 6:39 a.m.
edited Feb 22 '16, 6:46 a.m.
There is a report called Consolidated Tracker which has the column ToolsAccelerator.
Currently, the report looks like this


 
If there are 2 values of ToolsAccelerators, 2 rows are created.
But, If there are 2 or more values, we need them to be displayed in the Same row and column. separated by commas.Like this:


 

The ToolsAccelerator column is filled with entries that are fetched from a column called LITERAL_NAME which is present in a table called T11_1.
The Project Detail ID in the consolidated tracker is fetched from column REFERENCE_ID from a table called T2


Table T2:
 

For every Reference _id in T2, there is a corresponding Request_ID in T2.
The ToolsAccelerator value is fetched after the following conditions:

1. Request_ID of T2= REQUEST_ID of table T11

Table T11:
 

2. value in the Name column of T11 table is 'com.ibm.gbs.workitem.attribute.custom.ToolsAcceleratorsEnumerationList'

3. T11.VAL is equal to CONCAT(CONCAT('%|',T11_1.EXTERNAL_ID), '|%')

Table T11_1:
 

4.T11_1.PROJECT_ID=T2.PROJECT_ID

After all this, the correponding values of T11_1 table's LITERAL_NAME column is fetched.(in other words, ToolsAccelerator values are fetched)

Left Join statements are used to check the above conditions:


 



 

 

We have tried to implement the same using Listagg function, but did not get the correct output.Probably because of incorrect implementation.
Kindly advice how to implement this. Any suggestion would be appreciated.
Thank you.


3 answers



permanent link
Dhanya Saseendran (8831421) | answered Feb 22 '16, 7:30 a.m.
Rephrasing the question(since Rini is not having Access to Upload pictures)

There is a report called Consolidated Tracker which has the column ToolsAccelerator.
Currently, the report looks like this

If there are 2 values of ToolsAccelerators, 2 rows are created.
But, If there are 2 or more values, we need them to be displayed in the Same row and column. separated by commas.Like this:

The ToolsAccelerator column is filled with entries that are fetched from a column called LITERAL_NAME which is present in a table called T11_1.

Table T11_1:

The Project Detail ID in the consolidated tracker is fetched from column REFERENCE_ID from a table called T2.

Table T2:



For every Reference _id in T2, there is a corresponding Request_ID in T2.

The ToolsAccelerator value is fetched after the following conditions:
1. Request_ID of T2= REQUEST_ID of table T11

Table T11:



2. value in the Name column of T11 table is 'com.ibm.gbs.workitem.attribute.custom.ToolsAcceleratorsEnumerationList'

3. T11.VAL is equal to CONCAT(CONCAT('%|',T11_1.EXTERNAL_ID), '|%')

(Table T11_1 and T11 are displayed above)

4.T11_1.PROJECT_ID=T2.PROJECT_ID

After all this, the corresponding values of T11_1 table's LITERAL_NAME column is fetched.(in other words, ToolsAccelerator values are fetched)

Left Join statements are used to check the above conditions:

Sql querry used:






We have tried to use Listagg function, but did not get the correct output.Probably because of incorrect implementation.
Kindly advice how to implement this. Any suggestion would be appreciated.
Thank you.



permanent link
Dhanya Saseendran (8831421) | answered Feb 22 '16, 8:08 a.m.
Sample Querry for the above question :
SELECT  T1.REFERENCE_ID,
       T1.NAME,
       T4_1.LITERAL_NAME,
       T5_1.LITERAL_NAME AS LITERAL_NAME1,
       T2.REFERENCE_ID AS REFERENCE_ID1,
       T2.NAME AS NAME1,
       T2.REQUEST_TYPE,
       T6_1.LITERAL_NAME AS LITERAL_NAME2,
       T7_1.LITERAL_NAME AS LITERAL_NAME3,
       T8.FULL_NAME,
       T9_1.LITERAL_NAME AS LITERAL_NAME4,
       T10.VAL,
       T2.DUE_DATE,
      T11_1.LITERAL_NAME AS LITERAL_NAME5,
      T2.REQUEST_STATE,
      T15.VAL,
Max(case when  T3.REQUEST_TYPE='Initiation' then T3.REFERENCE_ID end )as Initiation_child_id ,
Max(case when  T3.REQUEST_TYPE='Initiation' then T3.NAME  end) as Initiation_child , 
Max(case when  T3.REQUEST_TYPE='Initiation' then T12_1.LITERAL_NAME  end) as Initiation_Child_Health_Status ,     
Max(case when  T3.REQUEST_TYPE='Initiation' then T13.VAL  end) as Initiation_Child_Planned_SD ,
Max(case when  T3.REQUEST_TYPE='Initiation' then T3.DUE_DATE  end) as Initiation_Child_DUE_DATE ,
Max(case when  T3.REQUEST_TYPE='Initiation' then T14.VAL  end) as Initiation_Child_Actual_ED ,
Max(case when  T3.REQUEST_TYPE='Initiation' then T16.VAL  end) as Initiation_Child_Actual_SD ,
Max(case when  T3.REQUEST_TYPE='Initiation' then T3.REQUEST_STATE  end) as Initiation_Child_Status ,
Max(case when  T3.REQUEST_TYPE='Implementation' then T3.REFERENCE_ID end) as Implementation_child_id,  
Max(case when  T3.REQUEST_TYPE='Implementation' then T3.NAME  end) as Implementation_child,
Max(case when  T3.REQUEST_TYPE='Implementation' then T12_1.LITERAL_NAME  end) as Implementation_Child_Health_Status,
Max(case when  T3.REQUEST_TYPE='Implementation' then T3.DUE_DATE  end) as Implementation__Child_DUE_DATE,
Max(case when  T3.REQUEST_TYPE='Implementation' then T13.VAL  end) as Implementation__Child_Planned_SD,
Max(case when  T3.REQUEST_TYPE='Implementation' then T14.VAL  end) as Implementation__Child_Actual_ED,
Max(case when  T3.REQUEST_TYPE='Implementation' then T16.VAL  end) as Implementation_Child_Actual_SD ,
Max(case when  T3.REQUEST_TYPE='Implementation' then T3.REQUEST_STATE  end) as Implementation__Child_Status,
Max(case when  T3.REQUEST_TYPE='Deployment' then T3.REFERENCE_ID end) as Deployment_child_id,
Max(case when  T3.REQUEST_TYPE='Deployment' then T3.NAME  end) as Deployment_child,
Max(case when  T3.REQUEST_TYPE='Deployment' then T12_1.LITERAL_NAME  end) as Deployment_Child_Health_Status,
Max(case when  T3.REQUEST_TYPE='Deployment' then T3.DUE_DATE  end) as Deployment__Child_DUE_DATE,
Max(case when  T3.REQUEST_TYPE='Deployment' then T13.VAL  end) as Deployment__Child_Planned_SD,
Max(case when  T3.REQUEST_TYPE='Deployment' then T14.VAL  end) as Deployment__Child_Actual_ED,
Max(case when  T3.REQUEST_TYPE='Deployment' then T16.VAL  end) as Deployment_Child_Actual_SD ,
Max(case when  T3.REQUEST_TYPE='Deployment' then T3.REQUEST_STATE  end) as Deployment__Child_Status,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T3.REFERENCE_ID end) as Benefitchild_id,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T3.NAME  end) as Benefitchild ,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T12_1.LITERAL_NAME  end) as BenefitChild_Health_Status,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T13.VAL  end) as Benefit__Child_Planned_SD ,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T3.DUE_DATE  end) as Benefit__Child_DUE_DATE ,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T14.VAL  end ) as Benefit__Child_Actual_ED,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T16.VAL  end) as Benefit_Child_Actual_SD ,
Max(case when  T3.REQUEST_TYPE='Benefit Realization' then T3.REQUEST_STATE  end ) as Benefit__Child_Status
FROM RIDW.VW_REQUEST T1
INNER JOIN RIDW.VW_REQUEST_RELATIONAL_LINK LT1
ON T1.REQUEST_ID = LT1.REQUEST2_ID AND LT1.NAME = 'com.ibm.team.workitem.linktype.parentworkitem'
  INNER JOIN RIDW.VW_REQUEST T2
  ON LT1.REQUEST1_ID = T2.REQUEST_ID AND LT1.NAME = 'com.ibm.team.workitem.linktype.parentworkitem'
    INNER JOIN RIDW.VW_REQUEST_RELATIONAL_LINK LT2
    ON T2.REQUEST_ID = LT2.REQUEST2_ID AND LT2.NAME = 'com.ibm.team.workitem.linktype.parentworkitem'
      INNER JOIN RIDW.VW_REQUEST T3
      ON LT2.REQUEST1_ID = T3.REQUEST_ID AND LT2.NAME = 'com.ibm.team.workitem.linktype.parentworkitem'
        LEFT OUTER JOIN RICALM.VW_RQST_STRING_EXT T4
        ON T4.REQUEST_ID=T1.REQUEST_ID AND T4.NAME='com.ibm.gbs.workitem.attribute.custom.IOT'
          LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T4_1
          ON T4_1.EXTERNAL_ID=T4.VAL AND T4_1.PROJECT_ID=T1.PROJECT_ID
            LEFT OUTER JOIN RICALM.VW_RQST_STRING_EXT T5
            ON T5.REQUEST_ID=T1.REQUEST_ID AND T5.NAME='com.ibm.gbs.workitem.attribute.custom.sector'
              LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T5_1
              ON T5_1.EXTERNAL_ID=T5.VAL AND T5_1.PROJECT_ID=T1.PROJECT_ID
                LEFT OUTER JOIN RICALM.VW_RQST_STRING_EXT T6
                ON T6.REQUEST_ID=T2.REQUEST_ID AND T6.NAME='com.ibm.gbs.workitem.attribute.custom.enum.ProjectType'
                  LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T6_1
                  ON T6_1.EXTERNAL_ID=T6.VAL AND T6_1.PROJECT_ID=T2.PROJECT_ID
                    LEFT OUTER JOIN RICALM.VW_RQST_STRING_EXT T7
                    ON T7.REQUEST_ID=T2.REQUEST_ID AND T7.NAME='com.ibm.gbs.workitem.attribute.custom.enum.ProjectState'
                      LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T7_1
                      ON T7_1.EXTERNAL_ID=T7.VAL AND T7_1.PROJECT_ID=T2.PROJECT_ID
                        INNER JOIN RIDW.VW_RESOURCE T8
                        ON T8.RESOURCE_ID=T2.OWNER_ID
                          LEFT OUTER JOIN RICALM.VW_RQST_STRING_EXT T9
                          ON T9.REQUEST_ID=T2.REQUEST_ID AND T9.NAME='health_status'
                            LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T9_1
                            ON T9_1.EXTERNAL_ID=T9.VAL AND T9_1.PROJECT_ID=T2.PROJECT_ID
                              LEFT OUTER JOIN RICALM.VW_RQST_TIMESTAMP_EXT T10
                              ON T10.REQUEST_ID=T2.REQUEST_ID AND T10.NAME='planned_start_date'
                                 LEFT OUTER JOIN RICALM.VW_RQST_STRING_M_EXT T11
                              ON T11.REQUEST_ID=T2.REQUEST_ID AND T11.NAME='com.ibm.gbs.workitem.attribute.custom.ToolsAcceleratorsEnumerationList'
                                LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T11_1
                                ON T11.VAL LIKE CONCAT(CONCAT('%|',T11_1.EXTERNAL_ID), '|%') AND T11_1.PROJECT_ID=T2.PROJECT_ID
                                    LEFT OUTER JOIN RICALM.VW_RQST_STRING_EXT T12
                                    ON T12.REQUEST_ID=T3.REQUEST_ID AND T12.NAME='health_status'
                                      LEFT OUTER JOIN RICALM.VW_RQST_ENUMERATION T12_1
                                      ON T12_1.EXTERNAL_ID=T12.VAL AND T12_1.PROJECT_ID=T3.PROJECT_ID
                                        LEFT OUTER JOIN RICALM.VW_RQST_TIMESTAMP_EXT T13
                                        ON T13.REQUEST_ID=T3.REQUEST_ID AND T13.NAME='planned_start_date'
                                          LEFT OUTER JOIN RICALM.VW_RQST_TIMESTAMP_EXT T14
                                          ON T14.REQUEST_ID=T3.REQUEST_ID AND T14.NAME='com.ibm.team.workitem.attribute.manualEndDate'
                                          LEFT OUTER JOIN RICALM.VW_RQST_TIMESTAMP_EXT T15
                                            ON T15.REQUEST_ID=T2.REQUEST_ID AND T15.NAME='com.ibm.gbs.workitem.attribute.DeepDiveDate'
                                            LEFT OUTER JOIN RICALM.VW_RQST_TIMESTAMP_EXT T16
                                          ON T16.REQUEST_ID=T3.REQUEST_ID AND T16.NAME='com.ibm.team.workitem.attribute.manualStartDate'
WHERE T1.PROJECT_ID = 134 AND
  T2.PROJECT_ID = 134 AND
  T3.PROJECT_ID = 134  AND
  T1.ITERATION_ID <> 3647 AND
  T2.ITERATION_ID <> 3647 AND
(  T1.REQUEST_TYPE = 'Account' AND
  T2.REQUEST_TYPE = 'Project Detail' AND
  (T3.REQUEST_TYPE = 'Benefit Realization' OR T3.REQUEST_TYPE = 'Deployment' OR T3.REQUEST_TYPE = 'Implementation' OR T3.REQUEST_TYPE = 'Initiation' )
) AND

(T1.ISSOFTDELETED = 0 AND T2.ISSOFTDELETED = 0 AND T3.ISSOFTDELETED = 0)
group by
 T1.REFERENCE_ID,
       T1.NAME,
       T4_1.LITERAL_NAME,
       T5_1.LITERAL_NAME ,
       T2.REFERENCE_ID ,
       T2.NAME ,
       T2.REQUEST_TYPE,
       T6_1.LITERAL_NAME ,
       T7_1.LITERAL_NAME,
       T8.FULL_NAME,
       T9_1.LITERAL_NAME,          
       T10.VAL,
       T2.DUE_DATE,
      T11_1.LITERAL_NAME,
      T2.REQUEST_STATE,
      T15.VAL
     


permanent link
Steven Shaw (55113) | answered Feb 24 '16, 3:53 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
 Hello,

I found an entry on Stack Overflow that might provide some tips on how to do this: http://stackoverflow.com/questions/194852/concatenate-many-rows-into-a-single-text-string

Otherwise in Report Builder we do have spanning capability where you can clear see how the next column spans from the previous.  If you sort the columns that you want to span, then spanning will kick in automatically.  You can see this if you add Test Category as a column when viewing Test Cases:
However, we do see the value in the functionality you mention.  We have a story that tracks this: 381389: Display of multi value attributes

Feel free to subscribe and/or vote for it to be incorporated in a future release of Report Builder.

Regards,

-Steve

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.