I have a result set from a series of operations that looks like:
myCDT:{
label: "some name",
data: 0,1,12,0,14,234
}
"data" is an integer array - but may have a variable number of Elements.I've got a List of myCDT's and want to create an array of integers that is the sum of each positional integer column (e.g add up all of data[1], data[2], etc)Any good ideas on how to do this?
Ultimately all I need is a total row in some grids, but there doesn't seem to be a way to do that.
Discussion posts and replies are publicly visible
try using the reduce() function docs.appian.com/.../fnc_looping_reduce.html
I think you can create a slice using index like
index(index(myCDT_Array,"data",{}),1,{})
You'll somehow need to manage the positional index as needed.
OK, so that takes me a bit further, what I'm actually dealing with deep down is a pseudo chartSeries construct that is appearing in a grid below a chart that has taken some careful programmatic assembly. So I very much have variable sizes at both dimensions. Still plugging, although this was a big help.
To generalize it you'll need to make a helper function:
getDataFromCDTList(cdtList, index)
Defined As:
apply(
fn!index(cdt, _, {}).data
1+enumerate(fn!length(ri!cdtList.data)
)
Then to help generate your chart series:
getDataFromCDTList(
cdtList: local!myCDTList,
index: _
),
fn!length(local!myCDTList[1].data)
There used to be a SAIL recipe that covered exactly this (what you're effectively doing is transposing tabular data) but I can't seem to find it anymore.