Chee Kheong Wan Posted October 6, 2023 Share Posted October 6, 2023 Example6329 => 96321234 => 4321985 => 98502002 => 22001 => 1000 Link to comment Share on other sites More sharing options...
Gaia Paolini Posted October 6, 2023 Share Posted October 6, 2023 I cannot see a way of doing it with a simple Spotfire expression. I would suggest to create the new column using a TERR expression function.To create it, go to menu > Data > Data Function Properties > Expression Functions tab.Then choose New.. and add a Column Function with return type Integer and category Statistical Function, using the following script:sort4digits = function(v) { vi=strsplit(as.character(v),'')[[1]] vi=sort(vi,decreasing=TRUE) vi=c(vi,rep(0,4-length(vi))) vi=as.integer(paste(vi,collapse='')) return (vi)} output = sapply(input1,sort4digits)The sort4digits function takes each integer, e.g. 6329, splits it into a vector, sorts the vector highest first, pads it with zeroes if shorter than 4, then re-collapses the four digits into an integer. Then the output column is created by applying this function to all rows.Call this expression function e.g. TERR_sortMe.Then create your new column as the following expression:TERR_sortMe([value])where [value] will be your original column. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now