Is there a smarter way to pick unique records being fetched by a query expression?

Hi All,

My name is Sam and i am new to Appian development and hence might be asking a few rudimentary questions. For this one, i have a query expression that is returning me a year value as {2019, 2019,2019,2018,2018,2017}. As you see this is returning values from different rows of a database. Now what i would like to do is get the unique values from this list so my output should like "{2019,2018,2017}". After studying the built in functions the only function i was able to use to achieve what i need was union () where my code looked like union((rule!<rule>(year)),rule!<rule>(year))) , where i am doing a union between the same set of data. Somehow i feel this is not efficient. Is there any other built in function that woudl allow me to extract the unique values from my array list with duplicates.

Any pointers would be helpful.

Thanks again community.

 

Reg,

Sam

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    A Score Level 1
    in reply to ManuelHTG
    by the way, always good to look for some query recipes.

    From here Appian recommends a very easy approach, to use the group parameter. That would be the best way as you would only have one call to the DB and as you dont need to process it after

    Check "Get the Distinct Values of a Field"

    docs.appian.com/.../Query_Recipes.html


    a!queryEntity(
    entity: cons!EMPLOYEE_ENTITY,
    query: a!query(
    aggregation: a!queryAggregation(
    aggregationColumns: {
    a!queryAggregationColumn(
    field: "department",
    isGrouping: true
    )
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: -1,
    sort: a!sortInfo(
    field: "department",
    ascending: true
    )
    )
    )
    ).data.department