Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
Expand all | Collapse all

Transpose #sq(CSVIdentityNameList ())#

  • 1.  Transpose #sq(CSVIdentityNameList ())#

    Posted Fri January 05, 2024 10:17 AM

    Hello, 

    Has anyone attempted to transpose the results of #sq(CSVIdentityNameList ())#

    Example the macro results will be something like  'Admin Administrator', 'Admin Project Member', 'Admin Shared Files Access', 'Admin Shared Files Developer', 'All Authenticated Users', 'Analytics Users' Can that be transposed as

    Admin Administrator
    Admin Project Member
    Admin Shared Files Access
    Admin Shared Files Developer
    All Authenticated Users
    Analytics Users

    Thank you,
    Udaya.



    ------------------------------
    Udaya Rani Palli
    ------------------------------


  • 2.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Mon January 08, 2024 12:06 PM

    Hello Udaya,
    You can use a CognosSQL statement that uses a row value constructor.  E.g.

    select IdName
    from
    values (
    #CSVIdentityNameList ('),(')#
     ) T(IdName)

    The macro will return something like     'a'),('b'),('c'
    This will then be surrounded by ( ) tokens, so you end up with 
               select IdName from values ('a'),('b'),('c') T(IdName)

    Cognos SQL needs a database connection, you can use any of the ones that the Data Module or FM Package is pointing to.



    ------------------------------
    Kind regards,
    Henk Cazemier
    ------------------------------



  • 3.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Wed January 10, 2024 02:02 PM

    Thank you Henk Cazemier, worked like a charm.

    Udaya.



    ------------------------------
    Udaya Rani Palli
    ------------------------------



  • 4.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Fri December 20, 2024 10:43 AM

    Hi Henk, 

    Sorry, this may be a noob question but I'm looking for this exact solution and am unable to make it work.  When I try this:

    select IdName
    from
    values (
    #sq(CSVIdentityNameList ('),('))#
     ) T(IdName)

    I get this error:

    XQE-V5-0017 V5 syntax error found for data item 'Testing1' of query 'Query1', invalid token "IdName" found after "select ".

    What is "IdName" supposed to reference?



    ------------------------------
    Ryan Enns
    ------------------------------



  • 5.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Mon January 06, 2025 03:58 PM

    Hi Ryan,

    It seems that you added an sq(  ) call in the macro expression. When you remove that call, does it then work properly?



    ------------------------------
    Kind regards,
    Henk Cazemier
    ------------------------------



  • 6.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Tue January 07, 2025 02:40 PM
    Edited by Ryan Enns Tue January 07, 2025 02:48 PM

    No, that still produces the same error.

    If I just do this, I still get the same error:

    #CSVIdentityNameList ()#

    But if I include the sq() call, it works (non-transposed, of course):

    #sq(CSVIdentityNameList ())#


    ------------------------------
    Ryan Enns
    ------------------------------



  • 7.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Tue January 07, 2025 03:46 PM

    Hi Ryan,

    Using #CSVIdentityNameList ()# will not work
    but what about when it is
    #CSVIdentityNameList ('),(')#
    If that produces an error, what is the message that you see?
    If it doesn't please let me know and we can jump on a call and see if we can figure out how to make it work with your scenario.



    ------------------------------
    Kind regards,
    Henk Cazemier
    ------------------------------



  • 8.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Tue January 07, 2025 04:05 PM

    Ah sorry, you're right.  Ok, when I use this:

    #CSVIdentityNameList ('),(')#

    I get this message:

    XQE-V5-0017 V5 syntax error found for data item 'Cognos User Roles' of query 'Query1', invalid token ")" found after "'All Authenticated Users'".

    Where 'All Authenticated Users' is the first result in the CSVIdentityNameList.  It follows with 'AllAuthenticatedUsers'),('All_Cognos_Users'),('AnalysisUsers'), etc.



    ------------------------------
    Ryan Enns
    ------------------------------



  • 9.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Tue January 07, 2025 04:08 PM

    Hi Ryan,
    I can set up a call with you and see where the issue lies, it seems to depend on the context where you're using it.
    Pls drop me a message at: henk.cazemier@ca.ibm.com



    ------------------------------
    Kind regards,
    Henk Cazemier
    ------------------------------



  • 10.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Tue January 07, 2025 07:06 PM

    Hello Ryan, 

    Sorry to jump in late in this discussion. I just copy pasted the sql and it works. Please see the screenshot how I implemented it in a report. 



    ------------------------------
    Udaya Rani Palli
    ------------------------------



  • 11.  RE: Transpose #sq(CSVIdentityNameList ())#

    Posted Wed January 08, 2025 10:59 AM

    Thank you Udaya, but unfortunately our system does not permit user-defined SQL.  

    Henk showed me how it can be accomplished by adding a Table based on SQL to the data module, but I'll need to involve my IT team to make those changes.  This is a very low-priority item, so it may not happen for a while.  

    Thank you both for your help with this.

     - Ryan



    ------------------------------
    Ryan Enns
    ------------------------------