Hi,
I have a table like that :
test | total | productA_xxxx | productA_zzzz | productB_xxxx | productB_zzzz |
1 | 22 | 0.23 | 0.36 | 0.44 | 0.55 |
What I want is a table like that :
test | total | object | xxxx | zzzz |
1 | 22 | productA | 0.23 | 0.36 |
1 | 22 | productB | 0.44 | 0.55 |
How can I extract "product" from the name of the field ?
Can you help me please ?
Thank you !
It nearly always helps to have a fuller picture! 😀
| makeresults
| eval _raw="test total productA_xxxx productA_zzzz productB_xxxx productB_zzzz
1 22 0.23 0.36 0.44 0.55"
| multikv forceheader=1
| fields - _* linecount
| eval testtotal=test."|".total
| fields - test total
| untable testtotal product value
| eval object=mvindex(split(product,"_"),0)
| eval product=mvindex(split(product,"_"),1)
| eval testtotalobject=testtotal."|".object
| xyseries testtotalobject product value
| eval test=mvindex(split(testtotalobject,"|"),0)
| eval total=mvindex(split(testtotalobject,"|"),1)
| eval object=mvindex(split(testtotalobject,"|"),2)
| fields - testtotalobject
| table test total object *
First, combine the common fields, then untable (this is the inverse of xyseries). Now split the product into object and product. Append the object to the common field, and put back into an xyseries. Finally, split out the components of the common field.
| makeresults
| eval _raw="product_xxxx product_zzzz
0.23 0.36"
| multikv forceheader=1
| fields - _* linecount
| transpose 0
| eval column=mvindex(split(column,"_"),1)
| transpose 0 header_field=column
| fields - column
| eval object="product"
Hi @ITWhisperer
I edited my post because it does not suit with my whole table.
Please look at my first post I have just edited.
Thanks a lot!
It nearly always helps to have a fuller picture! 😀
| makeresults
| eval _raw="test total productA_xxxx productA_zzzz productB_xxxx productB_zzzz
1 22 0.23 0.36 0.44 0.55"
| multikv forceheader=1
| fields - _* linecount
| eval testtotal=test."|".total
| fields - test total
| untable testtotal product value
| eval object=mvindex(split(product,"_"),0)
| eval product=mvindex(split(product,"_"),1)
| eval testtotalobject=testtotal."|".object
| xyseries testtotalobject product value
| eval test=mvindex(split(testtotalobject,"|"),0)
| eval total=mvindex(split(testtotalobject,"|"),1)
| eval object=mvindex(split(testtotalobject,"|"),2)
| fields - testtotalobject
| table test total object *
First, combine the common fields, then untable (this is the inverse of xyseries). Now split the product into object and product. Append the object to the common field, and put back into an xyseries. Finally, split out the components of the common field.