Using field number in an array

Pan 10.2.1/ Sequoia 15.2

Trying to create an array using field numbers instead of names

arrayselectedbuild lvArCat, cr(),“”,UPPER(«Account»[“-”,-1][2,-1])+tab()+field 1

gives me a syntax error

using

arrayselectedbuild lvArCat, cr(),“”,UPPER(«Account»[“-”,-1][2,-1])+tab()+round(fieldvalue(info(“fieldnumber”)+4),.01)

runs and gets the right value for the first record, but for the rest of the records the «Account» field is correct and the field number field is from the first record

I’ve also tried calculating the field number as shown in the Panorama Help, with and without various parentheses. No go

Does using a field number work in an array and I’m just missing something simple, or am thinking this through wrong?

Thanks

Of course it does. You can’t just make up your own syntax.

Well, let’s see what the documentation says.

Yup, it says “the current record”. Not “the record being scanned by the arraybuild function”. Based on your results, I assume that the current record is the first record.

Is there an actual reason why you want to specify the field by number instead of by name? In Panorama, fields are normally specified by name. Why don’t you just use the name?

If you really have an actual reason to do this, it is possible. But it’s rather convoluted. I’d rather not bother to explain it unless there is a good reason for this.

I’m just working on a project to process imported multi-year reports. The idea was to name the fields on the fly and extract some of the data via arrays. The field names would be year names , which would change depending on the year of the original data.
So it appears that just having the field name permanent is the way to go here.

Thanks

martinmc, not for nuting, but whenever I see something that is close to expanding the number of fields by dates - in year case, years - I wonder if that’s the best structure in the long run.

You might consider creating fields for the categories of that yearly content (assuming they don’t change) and have a DataYear field (integer type) for the import year.

That way, you can select all the data for one year by selecting on your DataYear field. You can show trends with summary records and maybe cross tabs.

The bottom line is, as much as possible, I’d think your database design shouldn’t need added fields each [your interval here]; it should just have added records.

1 Like

Paul is providing excellent advice here. :100:

Time to rethink;>

Thanks