Skip to main content
venkateshg4665
August 7, 2025
Solved

Accessing Values in Dictionary

  • August 7, 2025
  • 11 replies
  • 0 views

 

Hi team

I want to access values in a dictionary without using a loop, because in real-time we have 440 rows, and each row has 150 columns. Running a loop over each row to get values is causing performance issues.

I checked the Appian Community and found that we can use the a!keys() function to extract all keys

Id (PK), PartNumber, Status, Country_1, Country_2, Country_3, ..., Country_150

We are using CDT to get data from DB so output of CDT in dictionary format.

Expected output:
countries: {
{country_1, country_2, country_3, ..., country_150}----for 1 st row
{country_1, country_2, country_3, ..., country_150}-----for 2nd row
}
*** One way i found is writing index on all 150 columns  but it will increase code length  is ther other alternative way other than this
Best answer by shubhama926776
Running a loop over each row to get values is causing performance issues.

Simply, Use dot-notation/index/property to extract all columns at once without loops.

One way i found is writing index on all 150 columns  but it will increase code length  is ther other alternative way other than this

Code length does NOT affect performance - only execution complexity does. Writing 150 dot notation or index() statements executes much faster than loops.

Alternatively, 
Create an aggregated view: SELECT request_id, GROUP_CONCAT(country SEPARATOR ',') as countries_list FROM child_table GROUP BY request_id. Returns one row per request with comma-separated countries.
In Appian: split(local!data.countries_list, ",").

11 replies

stefanhelzle0001
August 7, 2025

Trying to manage 440 rows with 150 columns in memory does not feel like a good design decision.

What do you try to achieve?

venkateshg4665
August 7, 2025

[mention:a11f77a729fb4db2af76b09948583328:e9ed411860ed4f2ba0265705b8793d05] The table has a maximum of 150 entries for each ID. For example, for request ID 1, we have 120 eligible countries, so there are 120 rows in the child table. For request ID 2, there are 50 eligible countries, so we have 50 rows in the child table.

In the main table, if I have 440 rows, then in the child table I will have up to 440 × 150 rows. To avoid this many loops, I created a view with the format mentioned above — where each request ID has all countries as columns. This way, I only need to run 440 loops to get the request ID and all country values into one variable.

From that variable, I want to extract only the country values, not other values like the request ID.

harshas2775
August 7, 2025

If you join the tables using request id then you will have multiple rows for each id in the view instead of columns! Querying which you can get all 120 countries as a list in Appian and wont need any loop. Did you try this way? 

shubhama926776
August 7, 2025
Running a loop over each row to get values is causing performance issues.

Simply, Use dot-notation/index/property to extract all columns at once without loops.

One way i found is writing index on all 150 columns  but it will increase code length  is ther other alternative way other than this

Code length does NOT affect performance - only execution complexity does. Writing 150 dot notation or index() statements executes much faster than loops.

Alternatively, 
Create an aggregated view: SELECT request_id, GROUP_CONCAT(country SEPARATOR ',') as countries_list FROM child_table GROUP BY request_id. Returns one row per request with comma-separated countries.
In Appian: split(local!data.countries_list, ",").

venkateshg4665
August 7, 2025

 Thank you all for your time,

 [mention:9861aef97eb2483a8b76175d9eda1e37:e9ed411860ed4f2ba0265705b8793d05] 

Create an aggregated view: SELECT request_id, GROUP_CONCAT(country SEPARATOR ',') as countries_list FROM child_table GROUP BY request_id. Returns one row per request with comma-separated countries.
In Appian: split(local!data.countries_list, ",").

This is working fine and data loading without delay.

shubhama926776
August 7, 2025

That's good to know.

harshas2775
August 8, 2025

Hi [mention:02148ab3bf5743caac5bc4763aacac49:e9ed411860ed4f2ba0265705b8793d05]  I am aware you have a solution now yet I feel I couldn’t understand your usecase properly the other day and suggested to alter your existing view as solution. Though now I think a view is not needed  /appropriate for your use case at all.

Instead of a view you can query country column from the child table by request id within Appian expression rule so that the output you receive (the country names) will be a list of strings. In your main rule where you are creating this dictionary with the countries, you can use the function joinarray() with separator as comma(,) like below.

joinarray(local!listOfCountries,”,”) 

Here you need to replace the variable to variable that contains list of countries for given request id after querying data/ the expression rule that returns countries from child table. 

This doesn’t require a view and using a!foreach() you can get the expected output for each request id. 

venkateshg4665
August 11, 2025

[mention:65b14048184a4eb5aff3a76c87b97431:e9ed411860ed4f2ba0265705b8793d05] Thank you for your time,

The approach you're suggesting also works without using a nested for loop. However, we still need to call the child record inside the outer loop.
For example, if the number of rows is 440, then we would need to call the child record 440 times. This could lead to performance issues, especially since we can't load all child data at once, we have around 28,000 rows, and the record limit is 5,000.
Therefore, calling the record in each iteration of the outer loop becomes mandatory, which might impact performance.