cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Yass
Level II

How to creat a script that generat a Pareto Plot with date filters

Hello everyone,

 

I hope you're doing well. I'm facing an issue creating a script to generate a Pareto plot from a table that I want to filter by dates (date1 and date2).

As a first step, I called my table using:

dt2 = Open( "/D:/Project JMP/Tables/Table NOK PY.jmp", invisible );

Next :

dt2_top5 = dt2 << Summary(
	Group( :Date, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :CodeError),
	Freq( "Aucun(e)" ),
	Weight( "Aucun(e)" ),
	output table name( "Table2 Top 5" ),
	invisible
);

// Subset of data for Pareto plot filtered by Date
dt_pareto_subset = dt2_top5 << Select Where( Num( Char( :Date ) ) >= Num( date1 ) & Num( Char( :Date ) ) < Num( date2 ) );
dt_pareto_subset = dt2_top5 << Subset(
	Selected Rows(1),
	Columns(:CodeError),
	output table name("Pareto Subset"),
	invisible
);

and i did creat the Pareto plot in my window  :

Border Box(Left(25), Top(50), Bottom(200),
	V List Box(
		// Add the Pareto plot here
		paretoPlot = dt_pareto_subset << Pareto Plot(
			Y( :CodeError ),
			Freq( "Freq" ),
			Show Percents( 1 ),
			Show Cumulative Line( 1 )
		),
	)	
)

but after i lanched my script i did get this error :

Yass_1-1722243762584.png


The script object is expected when accessing or evaluating "Send", dt_pareto_subset << /*###*/
Pareto Plot(
               Y(:CodeError),

               Freq("Freq"),

               Show Percents(1),

               Show Cumulative Line(1)

)/*###*/

 

I have a small code snippet that generates a Pareto plot. Currently, I have to manually select the data table each time, and I cannot apply a date filter : 

Pareto Plot(
	Cause( :CodeError ),
	SendToReport(
		Dispatch( {"Plots"}, "Pareto Report", FrameBox, {Frame Size( 1555, 725 )} )
	)
);


Thank you all for your help,

Best regards,
Yass

5 REPLIES 5
jthi
Super User

Re: How to creat a script that generat a Pareto Plot with date filters

Do you have the subset you expect in dt_pareto_subset?

-Jarmo
Yass
Level II

Re: How to creat a script that generat a Pareto Plot with date filters

yes and i expect dt_pareto_subset to contain only the rows from dt2_top5 where the value in the :Date column falls between date1 and date2

jthi
Super User

Re: How to creat a script that generat a Pareto Plot with date filters

The error message is telling that the variable dt_pareto_subset doesn't have a scriptable object (in this case data table). There could many different causes for this and it is totally guess work without seeing your data or the full script.

-Jarmo
Yass
Level II

Re: How to creat a script that generat a Pareto Plot with date filters

 

Names Default To Here( 1 );

TOP5 = New Namespace(
    "TOP5"
);

TOP5:get_dates = Function({},
    ////
);

TOP5:calculate_nok_percentages = Function({dt},
    /////
);

// Define the Do function
TOP5:Do = Function ({nb_date1, nb_date2},
    //Ouverture de la table de données
    dt = Open( "/D:/Project JMP/Tables/TableData PY.jmp", invisible );
    dt2 = Open( "/D:/Project JMP/Tables/Table NOK PY.jmp", invisible );


    {percent_nok_ict, percent_nok_fct} = TOP5:calculate_nok_percentages(dt);

    current_month = Format(Today(), "Format Pattern", "<Month>", << Use Locale(0));

    date1 = Date Increment(Today(), "day", nb_date1, "start");
    date2 = Date Increment(Today(), "day", nb_date2, "start");

    dt_top5 = dt << Summary(
        Group( :Date, :Nom de fichier, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :Result, :CodeError),
        Freq( "Aucun(e)" ),
        Weight( "Aucun(e)" ),
        output table name( "Table Top 5" ),
        invisible
    );

    dt2_top5 = dt2 << Summary(
		Group( :Date, :Ref Produit, :ProductName, :Baie, :ICT_FCT, :CodeError),
		Freq( "Aucun(e)" ),
		Weight( "Aucun(e)" ),
		output table name( "Table2 Top 5" ),
		invisible
	);

	// Subset of data for Pareto plot filtered by Date
	dt_pareto_subset = dt2_top5 << Select Where( Num( Char( :Date ) ) >= Num( date1 ) & Num( Char( :Date ) ) < Num( date2 ) );
	dt_pareto_subset = dt2_top5 << Subset(
		Selected Rows(1),
		Columns(:CodeError),
		output table name("Pareto Subset"),
		invisible
	);


    /*
    //
    //
    //

    Here i have the logic of production repport.
    it's fine it works 
    
    //
    //
    //
    */


    //Création de la fenetre du top 5
    window = new Window ("TOP5",
        V List Box(
            pb = Picture Box( Open( "D:\Project JMP\Images\logo.png", png ) ),
            Border Box( Top(50),
                V List Box(
                    tb1 = Text Box("Production results report of "||Format( date2, "yyyy-mm-dd" )),
                    tb1 << Set Base Font( "Title" ),
                    tb1 << Set Font Scale (3),
                    tb1 << Justify Text("Center"),
                    tb1 << Set Width(2770),
                    tb1 << Background Color(RGB Color(225, 225, 225)),
                    
                    tb2 = Text Box ("SVI, PY"),
                    tb2 << Justify Text("Center") << Set Font Size(25),
                    tb2 << Set Width(2770),
                    tb2 << Background Color(RGB Color(240, 240, 240)),
                )
            ),
            V List Box (
                Border Box (Top (100), Bottom(100), Left (25),
                    H List Box(
                        // TOP 5 ICT
                        V List Box(
                            tb3 = Text Box( "Top 5 NOK results for ICT"),
                            tb3 << Set Base Font( "Title" ),
                            tb3 << Set Font Scale (2),
                            H List Box(
                                // column bay
                                
                                // column product ref
                                
                                // column test number
                                
                                //column %nok
                                
                                // column product name
                            )
                        ),	
                        V List Box(
							//nok percent for this month
						),
                    )
                ),
                Border Box(Left(25), Top(50), Bottom(200),
                    //TOP 5 FCT
                    V List Box(
                        tb4 = Text Box( "Top 5 NOK results for FCT"),
                        tb4 << Set Base Font( "Title" ),
                        tb4 << Set Font Scale (2),
                        H List Box(
                                // column bay
                                
                                // column product ref
                                
                                // column test number
                                
                                //column %nok
                                
                                // column product name
                            )
                        )
                        V List Box(
							//nok percent for this month
						),
                    )
                ),
                
                Border Box(Left(25), Top(50), Bottom(200),
					V List Box(
						// Add the Pareto plot here
						paretoPlot = dt_pareto_subset << Pareto Plot(
							Y( :CodeError ),
							Freq( "Freq" ),
							Show Percents( 1 ),
							Show Cumulative Line( 1 )
						),
					)	
				)
            )
        )
    );

    window << Maximize Window (1);
    //Enregistrement du fichier image .png et du fichier texte .txt
    window << Save Picture ("D:\Project JMP\Rapports de Production Quotidiens\Rapport du "||Format( date2, "yyyy-mm-dd" )||".png", "png");
    window << Save Text ("D:\Project JMP\Rapports de Production Quotidiens\Rapport du "||Format( date2, "yyyy-mm-dd" )||".txt");
);

 

 

jthi
Super User

Re: How to creat a script that generat a Pareto Plot with date filters

Does it work as intended if you create the plot after you have created the subset? So don't put it inside the new window

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Time Series/Steel Shipments.jmp");

dt << New Column("Errors", Character, Nominal, Formula(
	Match(Floor(:Steel Shipments / 1000),
		4, "1000",
		5, "2000",
		6, "3000",
		7, "4000",
		8, "5000"
	)
));

rows_of_interest = dt << Get Rows Where(02Feb1985<= :Date <= 09Jan1990);

dt_subset = dt << Subset(Rows(rows_of_interest), Selected Columns(0), Output Table("Subset"));

paretoplot = dt_subset << Pareto Plot(Cause(:Errors));
-Jarmo