Suppose I have 100 columns (actually 100+):
Plans (it does not have to be on this order, but you'll get the idea):
1. I want to retrieve the maximum value of each ROW.
Solution: "fieldsummary"
2. compare every value from each row(!) to its maximum value
3. count how many column from each row are less than the max-value.
let’s say:
row 7 (max = 10): column_11 < 10, column_47 < 10, column 59 < 10 —> if … set 1 or 0 … sum… = 3
row 19 (max = 34): column_2 < 43, column_53 < 43 —> if … set 1 or 0 … sum… = 2
4. retrieve the column name:
I'm thinking of „transpose“, but for 100+ columns, is it a good idea?
problem:
after executing "fieldsummary", I can’t have the original values from those 100 columns…
"fieldsummary" returns field, count, …max, mean, min…stdev, and values.
The values column consists of value and count.
Any idea how to display the original values AND the result from the "fieldsummary"?
I’ll give you something to start:
| makeresults count=7
| eval col_1=random() % 5 + 1
, col_2=random() % 5 + 1
, col_3=random() % 5 + 1
, col_4=random() % 5 + 1
, col_5=random() % 5 + 1
| foreach col_*
[eval cond_col_<> = if(<><= 2, 1, 0)]
| stats sum(cond_col_*) by _time
| stats max(sum(cond_col_*)) as max_cond_col* by _time
| foreach max_cond_col*
[eval col_name_<> = if(<> = **_max_value_from_fieldsummary**, "<>", "") ]
| table col_name_*
| eval combi = "", temp = ""
| foreach col_name_*
[eval temp = if(col_name_<>!="", "<>, ", "")
| eval combi=if(temp != "fake", tostring(temp).combi, "")]
—> "**_max_value_from_fieldsummary**". -> try to change it to something, for example: 3.
but how to extract this value from "fieldsummary" and still having the result of the 100 columns?
--> funny part: *if(temp != "fake"*, --> I want to compare it to empty string "", but it will take only the last column if the last column meets the condition. If not, the result is empty. Please try that yourself. I would say, this is a bug...:)
Thank you!
↧