Jump to content

My script below performs sorting with Sum(ColA), but does not work with Sum(ColA) / Sum(ColB) or Avg(ColA). How to make it work? Thanks

ron quach 2

Recommended Posts

Hi @ron quach​ would it be possible to share the dxp? Include a small dummy dataset representative of what you are using? It will then be easier for anyone looking at this to provide more specific script troubleshooting suggestions. Its not clear what type of error messages you are getting for example.



Link to comment
Share on other sites

Hi Hellen,

Here is the sample dxp. The script will sort the combo chart "Sort x-axis by" ok with myCategoryKey1=CategoryKey("Sum(Out)"),

but it incorrectly sorts if I use myCategoryKey2=CategoryKey("Sum(Out)/Sum(In)") . Sum(Out)/Sum(In) = Yield %.



Use Script it has incorrect Sort by Yield% or Sum(Out)/Sum(In)


Use "sort x-asis by" has correct sort by Yield% or Sum(Out)/Sum(In)


Link to comment
Share on other sites

Thanks Gaia. It works.

I want to select any Y-Axis value, IN, OUT, Yield %, from the list box ${SortOpitons} then sort it, but it does not work.

Please help.




from Spotfire.Dxp.Application.Visuals import CategoryKey

from Spotfire.Dxp.Application.Visuals import CombinationChart

#Define sorting myCategoryKey

# myCategoryKey1=CategoryKey("Sum(Out)")


#Perform sorting


Link to comment
Share on other sites

The document property needs to go into the script as an input parameter. I changed the values assigned to the drop down list (I don't think the as [..] construct works (there is no need for that anyway), and Yield % needs to be referred as such, re: my previous answer (I am not sure why, but since it works manually, it will work in a script).

Attached the modified dxp.

Link to comment
Share on other sites

I think the issue is still what you choose as value (Expression) in your dropdown. 

You need to look at what the manual options are and set them exactly the same way in your dropdown -> script.

So if you open your chart's Properties, go to Appearance, you see what is listed under Sort x-axis by: 

That is what you want to use in your dropdown. I see your options are now 'IN', 'OUT' and 'Yield %'.

I don't mean the Display Name (what people see), I mean the actual Expression (what is sent to the script.)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...