Skip to main content
June 7, 2024
Solved

How get one specific column from array of local variable data

  • June 7, 2024
  • 7 replies
  • 0 views

Hi 

I have one local variable and it has array of data in that i want one specific column data from each index and need to add those column data

for example:

local!test:

1. testid=1,testname="qwerty",testtime=9,testcomments="testtest"

2. testid=1,testname="qwerty",testtime=6,testcomments="testtest"

3.testid=1,testname="rest",testtime=1,testcomments="testtest"

Now from first index testtime ,secondindex testtime and third index testtime needs to be added and output should be 16 i tried foreach with using index but it didn't worked could you please suggest on this

Best answer by dharanik2600

Thank you every one it worked ,i tried in correct way only using sum(index(local!test,"columnname",{}) but i missed to refer the column with recordtype instead i directly called with columnname double quotes 

7 replies

venkatrea696188
June 7, 2024

a!localVariables(
  local!test:{a!map(testid:1,testname:"qwerty",testtime:9,testcomments:"testtest"),
 a!map( testid:1,testname:"qwerty",testtime:6,testcomments:"testtest"),
  a!map(
    testid:1,testname:"rest",testtime:1,testcomments:"testtest"
  )},
  sum(local!test.testtime)
)

You don't have to use foreach just go with sum and index the field . Refer above code

June 7, 2024

Thank you for this 

but the array of values was not limited to 3 it can be more also and also in a!map do i need to pass all columns data for all items(example 3 here) cant we pass index like that could you please suggest

venkatrea696188
June 7, 2024
but the array of values was not limited to 3 it can be more also and also in a!map do i need to pass all columns data for all items(example 3 here) cant we pass index like that could you please suggest

I just copied your data that's it. I don't get what you are exactly saying , but as longs as your data (how many rows it may be) has that field that you want to add, sum is going to work fine .And no need for columns ,If you are not using it anywhere  just get the required fields.

jayaprakashr0001
Participating Frequently
June 7, 2024

You can use Sum() function to achieve this. 

lokeshk0623
June 7, 2024

directly use sum function with a parameters

dharanik2600AuthorAnswer
June 7, 2024

Thank you every one it worked ,i tried in correct way only using sum(index(local!test,"columnname",{}) but i missed to refer the column with recordtype instead i directly called with columnname double quotes 

venkatrea696188
June 7, 2024

Good to know, Verify the answer so question is marked as closed