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
  • 0
    Certified Lead Developer
    For dead simplicity:

    local!originalData: a!queryEntity(...),
    local!condensedData: union(local!originalData, local!originalData)

    You grab all the data, you keep all of it should you need it, but you also get a smaller list of unique values to use where appropriate, and 1 call to the DB.

    This might be the preferred solution for a small number of rows, but if it gets big, you're going to see the grouping aggregation save your bacon. You're going to want less data in your server's RAM and less data coming from the database. But for smallish data this might be a little faster. You'll have to benchmark and see.

    uniqueValues() would be a very handy, dandy function for Appian to implement, if it didn't amount to self union under the hood.
Reply
  • 0
    Certified Lead Developer
    For dead simplicity:

    local!originalData: a!queryEntity(...),
    local!condensedData: union(local!originalData, local!originalData)

    You grab all the data, you keep all of it should you need it, but you also get a smaller list of unique values to use where appropriate, and 1 call to the DB.

    This might be the preferred solution for a small number of rows, but if it gets big, you're going to see the grouping aggregation save your bacon. You're going to want less data in your server's RAM and less data coming from the database. But for smallish data this might be a little faster. You'll have to benchmark and see.

    uniqueValues() would be a very handy, dandy function for Appian to implement, if it didn't amount to self union under the hood.
Children
No Data