Retrieve values based on another value

I need to find packing_unit_* where _text = PCS and based on the number “*” find values in packing_unit_oversized*.

In this case, I need to retrieve and store the __text from packing_unit_oversized_2 and packing_unit_oversized_3 because PCS is in packing_unit_2 and packing_unit_3.

Is there a way to do this other than using a “code transformer”?

{
	"specification": {
		"list-by-lang": {
			"attribute": [
				{
					"_id": "packing_unit",
					"__text": "1PCSETUP"
				},
				{
					"_id": "packing_unit_2",
					"__text": "PCS"
				},
				{
					"_id": "packing_unit_3",
					"__text": "PCS"
				},
				{
					"_id": "packing_unit_4",
					"__text": "PALLET"
				},
				{
					"_id": "packing_unit_bks",
					"__text": "1"
				},
				{
					"_id": "packing_unit_bks_2",
					"__text": "1"
				},
				{
					"_id": "packing_unit_bks_3",
					"__text": "2"
				},
				{
					"_id": "packing_unit_bks_4",
					"__text": "15"
				},
				{
					"_id": "packing_unit_d",
					"__text": "590.0000"
				},
				{
					"_id": "packing_unit_d_2",
					"__text": "1005.0000"
				},
				{
					"_id": "packing_unit_d_3",
					"__text": "730.0000"
				},
				{
					"_id": "packing_unit_d_4",
					"__text": "1200.0000"
				},
				{
					"_id": "packing_unit_oversized",
					"__text": "1"
				},
				{
					"_id": "packing_unit_oversized_2",
					"__text": "2"
				},
				{
					"_id": "packing_unit_oversized_3",
					"__text": "3"
				},
				{
					"_id": "packing_unit_oversized_4",
					"__text": "3"
				},
				{
					"_id": "packing_unit_s",
					"__text": "635.0000"
				},
				{
					"_id": "packing_unit_s_2",
					"__text": "665.0000"
				},
				{
					"_id": "packing_unit_s_3",
					"__text": "600.0000"
				},
				{
					"_id": "packing_unit_s_4",
					"__text": "800.0000"
				},
				{
					"_id": "packing_unit_sendable",
					"__text": "0"
				},
				{
					"_id": "packing_unit_sendable_2",
					"__text": "1"
				},
				{
					"_id": "packing_unit_sendable_3",
					"__text": "1"
				},
				{
					"_id": "packing_unit_sendable_4",
					"__text": "1"
				},
				{
					"_id": "packing_unit_v",
					"__text": "982.0000"
				},
				{
					"_id": "packing_unit_v_2",
					"__text": "85.0000"
				},
				{
					"_id": "packing_unit_v_3",
					"__text": "135.0000"
				},
				{
					"_id": "packing_unit_v_4",
					"__text": "2200.0000"
				}
			],
			"_lang": "eu"
		}
	}
}

Hi @vosy ,

Can you import and try this transformer whether it can achieve your needed?
Retrieve values based on another value.ndjson (2.9 KB)

Hi Arief, thank you very much! a lot, but how to convert
[
“2”,
“3”
]
to array of number and get MAX value?
thank you very much!

Hi @vosy

You can use value mapper as follow :

hi, thank you very much!, it works.
but Wouldn’t it be better to first convert the array of strings to an array of integers?

Id like to know for future how to simply convert array of string to array of int.

Hi @vosy,

Yes, you’re correct, the better way is to convert into integer first before get the maximum value. Therefore, the transformer will be 2 “value mappers” as follow :

The first “value mapper” is to convert array of string to array of int

Hi, thank you very much!, how simply.
I didnt think of use star on the end in pattern for setter “result.*” thank you very much!

1 Like