Drawing pivots using a script

Optuma Forums Optuma Scripting Drawing pivots using a script

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #51575
    • Topics: 15
    • Replies: 20
    • Posts: 35

    Ok – so I thought I’d try creating a script to add / remove pivot lines to my charts – but I’ve fallen at the first hurdle.


    My script (so far) is:

    PP = pivots(PIVOTS=Monthly);
    R1 = pivots(DEFAULT=R1, PIVOTS=Monthly);
    R2 = Pivots(DEFAULT=R2, PIVOTS=Monthly);
    R3 = pivots(DEFAULT=R3, PIVOTS=Monthly);
    S1 = pivots(DEFAULT=S1, PIVOTS=Monthly);
    S2 = pivots(DEFAULT=S2, PIVOTS=Monthly);
    S3 = pivots(DEFAULT=S3, PIVOTS=Monthly);

    However this gives me an error message in the script editor – ‘Please enter a valid script to add this criteria’

    Next step is to plot these variables, however I’m not sure what I’m missing above.



    Trevor R
    • Topics: 109
    • Replies: 318
    • Posts: 427

    Hi Steve,

    I’m guessing that this is what you were hoping to see:

    20190312 Steve's Scripts


    The first issue with your scripts is that you’ve assigned variable codes, R1, R2, R3 S1, etc that are the same as parameters used in the PIVOTS() function, eg PIVOTS(DEFAULT=R1, PIVOTS=Monthly) . This will cause the Function to try and call that variable of the same name – a No No! Thus I’ve started all those variables with a “v” to distinguish them from the function parameters.

    Next you need to define the Plots you wish to display. So here is the script code that I used to generate the above chart with SHOWPLOT tool calling the script:

    // Steve Script – Script Forum #51575 20190312

    PP = pivots(PIVOTS=Monthly);

    vR1 = pivots(DEFAULT=R1, PIVOTS=Monthly);

    vR2 = Pivots(DEFAULT=R2, PIVOTS=Monthly);

    vR3 = pivots(DEFAULT=R3, PIVOTS=Monthly);

    vS1 = pivots(DEFAULT=S1, PIVOTS=Monthly);

    vS2 = pivots(DEFAULT=S2, PIVOTS=Monthly);

    vS3 = pivots(DEFAULT=S3, PIVOTS=Monthly);

    Plot1 = PP; Plot1.Colour = Red;

    Plot1.LineStyle = Solid;

    Plot2 = vR1;

    Plot2.Colour = Blue;

    Plot2.LineStyle = Dash;

    Plot3 = vR2;

    Plot3.Colour = Blue;

    Plot3.LineStyle = LongDash;

    Plot4= vR3;

    Plot4.Colour = Blue;

    Plot4.LineStyle = DashDot;

    Plot5 = vS1;

    Plot5.Colour = Green;

    Plot5.LineStyle = Dash;

    Plot6 = vS2;

    Plot6.Colour = Green;

    Plot6.LineStyle = LongDash;

    Plot7= vS3;

    Plot7.Colour = Green;

    Plot7.LineStyle = DashDot;

    Incidentally, if you are wanting a result to use with a SHOWBAR, the final result of your script must not have a “;”, all other lines in the script must have one.



    The Auld Tyma at

    Auld Tyma Data Logo with URL 1 cm


    • Topics: 15
    • Replies: 20
    • Posts: 35

    Yes – that’s put me on the right course. Thanks Trevor for the help.    



    PS – I’ve gone to adjust the pivot colours – is there an alphabetical list of available colours? (ie the name of the colour to use within the script – sure red, green, blue is fine but is it light grey, teal / aqua? etc ).  I’ve gone looking but haven’t found anything.



    • This reply was modified 2 years ago by Steve.
    • Topics: 5
    • Replies: 487
    • Posts: 492

    Hi Steve,

    When you are typing in the Plot colour line of the script a drop down window will display to show you all available options.  You can see more information on how to setup multi-plot scripts (including colours) here:


Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest