Nick Napier Posted January 16, 2019 Share Posted January 16, 2019 I'd like to have a property control to toggle between different y-axis functions. The expression WeightedAverage([Weighting Factor],Min([NUMERIC_1]) over (Intersect([CAT_1],[CAT_2],[DATE_1]))) THEN Avg([Value]) OVER (LastPeriods(10,[Axis.X])) THEN If(Count() OVER (LastPeriods(10,[Axis.X]))=10,[Value],null) works correctly when I right-click the y-axis and enter it as a custom expression. However, when I enter it in the property control, I get the error "The 'THEN' keyword cannot be used in this context." How can I fix this I've attached photos and a .dxp file. Thanks! Link to comment Share on other sites More sharing options...
Gaia Paolini Posted January 17, 2019 Share Posted January 17, 2019 Hi Thanks for uploading the example. I think your version does not work because when you edit the custom expression directly on the axis, the column [Axis.X] can be interpreted. When you create it as a property control, it is out of context, as you see [Axis.X] is red in your formula. It must be interpreted by a different mechanism. I have an idea to work around it, see attached dxp. It is created with Spotfire 7.14, so in case you cannot open it I am adding the explanation. I noticed that setting Period=1 is equivalent to not smoothing, so: I created an integerproperty control called SmoothingPeriod. In the drop-down it is assigned to 1 (Non-smoothed) and 10 (Smoothed). The formula on the Y axis is now: WeightedAverage([Weighting Factor],Min([NUMERIC_1]) over (Intersect([CAT_1],[CAT_2],[DATE_1]))) THEN Avg([Value]) OVER (LastPeriods(${SmoothingPeriod},[Axis.X])) THEN If(Count() OVER (LastPeriods(${SmoothingPeriod},[Axis.X]))=${SmoothingPeriod},[Value],null) as [smoothed over ${SmoothingPeriod}] So every reference to Axis.X is already in the custom expression. Gaia 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