Hi community,
I want to write a function to add columns that have names that has a given prefix, and give values to the columns based on given conditions. This is the script that I have, but it errors out "Unresolved Column". I double checked everything and don't know where went wrong...
Much appreciated for the help!
add_extra_columns = Function( {dt, prefix},
{Default Local},
dt << New Column( "Data Usable?",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set each value(
If(
!Is Missing(
Column( dt, add_prefix_to_col_name( "Image", prefix ) ),
If( Column( dt, add_prefix_to_col_name( "Status", prefix ) ) == "Failed",
0,
If(
Is Missing( Column( dt, add_prefix_to_col_name( "Area Ratio", prefix ) ) ) &
Column( dt, add_prefix_to_col_name( "Shape", prefix ) ) != "Square",
0,
If(
Column( dt, add_prefix_to_col_name( "Status", prefix ) ) == "Succeeded" |
Column( dt, add_prefix_to_col_name( "Status", prefix ) ) == "Warning",
1
)
)
)
)
)
)
)
);
add_prefix_to_col_name = Function( {col_name, prefix}, // folder_path: the "\" at the end of the string is necessary
{Default Local},
If( prefix == "",
new_name = prefix || col_name,
new_name = prefix || " " || col_name
);
Return( new_name );
);
Sie scheinen eine einzelne Spalte mit dem Namen „Verwendbare Daten?“ zu erstellen und keine Spalten mit bestimmten Präfixen. Normalerweise möchten Sie vielleicht Column() in As Column() innerhalb Ihres „Set Each Value“ ändern, aber ich bin mir nicht ganz sicher, was Sie versuchen.