Automate

 View Only
Expand all | Collapse all

Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

  • 1.  Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Posted 20 days ago

    Hi Community,

    I need to query a "Reference Data List" with multiple criteria and insert the result aggregated into unique records into a "Repeating Table" element of my form.

    To do this, I use a "Query Element" in my form with SQL code as a "Raw Query." The code contains the selection conditions and the SQL statement "GROUP BY."

    After unsuccessful research in the Precisely documentation, the Knowledge Community, and the entire Internet, I found out through numerous attempts what the code for the "Query" parameter should look like.

    Ein Bild, das Text, Screenshot, Software, Display enthält.

KI-generierte Inhalte können fehlerhaft sein.

    Important: Following conditions must be met!

    1. "Raw Query" must be selected.

    2. The code in the "Query" property does not contain SELECT, FROM, or WHERE.

    Ein Bild, das Text, Screenshot, Schrift, Dokument enthält.

KI-generierte Inhalte können fehlerhaft sein.

    3. The syntax follows SQL standards ("=" instead of "==", 'AND' instead of "&&", etc.).

    4. In the "Data Connection," all (!) columns of the "Reference Data List" addressed by the "Query" code and the "Set Fields" property must be selected.

    Ein Bild, das Text, Screenshot, Schrift, Zahl enthält.

KI-generierte Inhalte können fehlerhaft sein.

    Ein Bild, das Text, Schrift, Zahl, Reihe enthält.

KI-generierte Inhalte können fehlerhaft sein.

    Ein Bild, das Text, Schrift, Zahl, Reihe enthält.

KI-generierte Inhalte können fehlerhaft sein.

    5. The GROUP BY statement in the "Query" code must also contain all addressed columns, including those that are only used for selection!

    Ein Bild, das Text, Schrift, Screenshot enthält.

KI-generierte Inhalte können fehlerhaft sein.

    6. The "Automatically retrieve data when form is opened" option can be selected in the "Data Connection", but does not have to be.

    Ein Bild, das Text, Screenshot, Schrift, Algebra enthält.

KI-generierte Inhalte können fehlerhaft sein.

    7. In the "Query Element," "Append to Repeating Group" does not have to be selected in order to fill the form element with data.

    If all these conditions are met, the "Query Element" successfully fills the "Repeating Table" element in the form with grouped values.

    However, this does not work reliably with unique records, as the columns with the selection criteria must also be grouped.

    This leads to ambiguous records in the "Repeating Table" element.

    Ein Bild, das Text, Screenshot, Software, Computersymbol enthält.

KI-generierte Inhalte können fehlerhaft sein.

    So there is no real grouping as in proper SQL.

    My questions are:

    A. How to setup the "Query Element" correctly, so that the GROUP BY statement only outputs unique records via the output columns only?

    B. What alternatives may applicable instead of a „Query Element" to get unique records into a „Repetaing Table" element?

    I would welcome any suggestions for a solution to my problem.

    Many thanks in advance.

    Regards

    Norbert



    ------------------------------
    Norbert
    ------------------------------


  • 2.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 19 days ago

    Hi Norbert,

    Is it possible if you can share the reference data list and a sample solution.

    Though you explained it really well, but it will be easier if you can provide the solution with relevant reference list, i can run a few tests and let you know.

    Regards



    ------------------------------
    Hammad Naeem
    *Precisely Software Inc.
    ------------------------------



  • 3.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Posted 19 days ago

    Thanks Hammad,

    for your quick response.

    I would be happy to provide you my test solution and reference data list, but your "Upload file" function doesn't except .wzip or .zip files. Only .xlsx would be possible.

    Please show me a way to post the files.

    Regards



    ------------------------------
    Norbert
    ------------------------------



  • 4.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 19 days ago

    Hi Norbert,

    You can upload the files on NowTransfer.de and share the download link.

    Regards



    ------------------------------
    Hammad Naeem
    *Precisely Software Inc.
    ------------------------------



  • 5.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 19 days ago

    Hi Norbert

    Only time for a quick thought. Did you use the SORT BY for the data connection?  You can add one or several fields.

    Happy to take a look, as well.  

    Also if you want to upload a solution, you can zip it up and upload the zip file.

    Best Regards,

    Sigrid



    ------------------------------
    Sigrid Kok
    *Precisely Software Inc.
    ------------------------------



  • 6.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Posted 16 days ago
      |   view attached

    Hello Sigrid,

    no I haven't yet added Sort Fields in the data connection. As well no SORT BY in the query code.

    Please find attached a zip file with my test data (test solution, reference list to be queried and EXCEL file with data from reference list).

    Appreciate your feedback.

    Regrads 



    ------------------------------
    Norbert
    ------------------------------

    Attachment(s)

    zip
    zTest_NP.zip   74 KB 1 version


  • 7.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 15 days ago

    Hi Norbert,

    Your solution is perfectly fine. I've just made a small change to the query - I removed the <> from the NOT LIKE condition, as it isn't required.

    The final query is provided below. Other than removing <>, no additional changes were made to the original query.

     
    [MM_Packaging_Unit] = 'PC' 
    AND ([Criteria_Material_Type] LIKE '%[/my:myFields/my:MM_Material_Type]%'  OR [Criteria_Material_Type] = '*') 
    AND ([Criteria_Plant] = '[/my:myFields/my:Plant_1] ' OR [Criteria_Plant] = '*' OR [Criteria_Plant] = '[/my:myFields/my:Plant_1]*')
    AND ([Criteria_Packaging_Type] LIKE '%[/my:myFields/my:HLP_Container_Type_PH]%' OR [Criteria_Packaging_Type] = '*') 
    AND  [Criteria_Packaging_Type] NOT LIKE '%[/my:myFields/my:HLP_Container_Type_PH]%'  
    AND [Status] = 'public' 
    GROUP BY 
    [Criteria_Plant],
    [Criteria_Material_Type],
    [Criteria_Packaging_Type], 
    [Status], 
    [MM_Label_Category],
    [MM_Packaging_Unit],
    [MM_Label_Size],
    [MM_Generation_Variant],
    [MM_Copies]
    I'm attaching the updated solution for your reference.

    Regards,



    ------------------------------
    Divya Verma
    *Precisely Software Inc.
    ------------------------------



  • 8.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Posted 15 days ago

    Thanks Divya,

    for your try. But before testing your suggestion: What do you hope to achieve with your suggestion to change the filter condition? Please note the contradiction between the two filter criteria:

    ... AND ([Criteria_Packaging_Type] LIKE '%[/my:myFields/my:HLP_Container_Type_PH]%'  ...

    versus 

    ... AND  [Criteria_Packaging_Type] NOT LIKE '%[/my:myFields/my:HLP_Container_Type_PH]%'

     ...

    I suspect that this does not solve my actual GROUP BY problem.

    Please keep on trying on a solution.

    Regards



    ------------------------------
    Norbert
    ------------------------------



  • 9.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 15 days ago

    Hi Norbert,

    The contradiction you mentioned already exists in your original query - I have verified this. My change was limited only to removing the <> from the NOT LIKE condition and did not introduce any new logical conflict.

    Regarding the GROUP BY, it is working correctly and grouping the similar rows as expected. I have tested it, and the results are consistent.

    Please find attached a screenshot of the output generated from your query for your reference.

    Let me know if you would like me to further analyze the grouping logic.

    Thanks.



    ------------------------------
    Divya Verma
    *Precisely Software Inc.
    ------------------------------



  • 10.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Posted 14 days ago

    Sorry Verma,

     I have to disagree:

    The "<>" can be intentional part of a criterion in the reference data list. So please note, for example the packaging type criterion "<>SA" in the reference data list.

    This excludes the label data within this row for materials of packaging type "Sack" (bag).

    So for instance: when searching for label data to packaging type "SA", the query must consider all rows in the reference data list where packaging type contains "SA" and (!) ignore those rows where this packaging type explicitly is excluded by "<>SA".

    In your screenshots of outputs generated, I miss several other label data (e.g. ZLB_PRCN) also fitting to your search criteria (assumingly: MM_Material_Type "IDEN" + Plant1 "310" + HLP_Container_Type_PH "KA".

    This is because your code includes "KA" by LIKE and excludes "KA" by NOT LIKE at same time. So only the rows with packaging type "*" are considered for output.

    Please do not change the selection criteria within the code, but investigate more focus on the GROUP BY functionality.

    P.S.: In case the character string "<>" within the code is interpreted by the system as a not equal operator, please show me how to code it explicitly as text.

    Regards



    ------------------------------
    Norbert
    ------------------------------



  • 11.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 14 days ago

    Hi Norbert,

    As far as I can tell, it is sorting but not "de-duplicating" (rolling up) based on the fields you selected to display like a SQL statement would with a subset of fields in a table/view. Instead it looks to be based on all of the fields, and you are only showing a small subset of them - thus they look like duplicates.

    I imagine there may be a way to do this through (1) putting the data in SQL and using a SQL statement with a group by or potentially (2) using javascript.

    Best Regards,

    Sigrid



    ------------------------------
    Sigrid Kok
    *Precisely Software Inc.
    ------------------------------



  • 12.  RE: Automate EVOLVE - How to query Reference Data List by Query Element using GROUP BY

    Employee
    Posted 13 days ago
    Edited by Divya Verma 13 days ago

    Hi Norbert,

    Thank you for your clarification. I understand that you would like to retrieve unique records based on a few specific columns.

    Currently, when grouping is applied, it merges duplicate rows into a single row. However, in your case it may not appear as expected because the GROUP BY is applied to all columns, while the Repeating Table is only displaying a subset of those columns. This can make some rows appear as duplicates.

    If you map all the columns from the query to the Repeating Table, you should see the correct aggregation and notice the difference.

    I can also prepare a sample solution that includes a query with fewer columns in the SELECT, criteria, and GROUP BY clause to provide a clearer view, if that would be helpful.



    Best Regards,



    ------------------------------
    Divya Verma
    *Precisely Software Inc.
    ------------------------------