Jump to content

Is it possible to rename expressions that become axis labels within other expressions? Using "as" to rename expressions...


JP Lee

Recommended Posts

Here is an expression for the Y axis of a scatter plot, which uses "as" at the end of the entire expression to rename the axis label:

if(

      "${TimeAxisType}" = "A",

      uniqueCount([XYZ]) over (Intersect([Axis.X],[Axis.Panels])), //simple count

      uniqueCount([XYZ]) over (Intersect(AllPrevious([Axis.X]),[Axis.Panels])) //cumulative count

      ) as [count]

I want to change the label based on the chosen expression however - something like this:

if(

      "${TimeAxisType}" = "A",

      uniqueCount([XYZ]) over (Intersect([Axis.X],[Axis.Panels])) as [count], //simple count

      uniqueCount([XYZ]) over (Intersect(AllPrevious([Axis.X]),[Axis.Panels])) as [cumulative count], //cumulative count

      )

But this yields a syntax error. My actual example has five of these subexpressions in the if() expression. Is there any way to do this?

thanks,

JP

Link to comment
Share on other sites

Hello JP,

You can only set "as" on the top level. Maybe you could handle this using two document properties, adding an additional property for the axis label.

  

So, I now have these properties: 

AxisType

AxisLabel

My plot-axis expression is this:

If(

"${AxisType}"="A",

[Population],

[urban Population %]

) as $esc(${AxisLabel})

I add a script on the AxisType property, that will run when it changes, to set the AxisLabel 

if Document.Properties["AxisType"]=="A":

Document.Properties["AxisLabel"] = "A title"

elif Document.Properties["AxisType"]=="B":

Document.Properties["AxisLabel"] = "B title"

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...