cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Yass
Level IV

Bad Argument( Scriptable[] )

Hello everyone,

I have a problem with my script, i want to do a study :
It's about filtering the IDs, avoiding IDs that are empty, equal to "-" or equal to "NOK". Then, these filtered IDs should be placed in a new table called dt_id_tri with the following columns: Ref Produit, Baie, and ID. After that, take a Ref Produit from the dataset and calculate the total number of duplicates (nb_total_doubl) for that Ref Produit, and include it in a JMP report with the message: 'The total number of duplicates for Ref Produit: ' || Ref Produit || ' is: ' || ...
For the second part, do the same for all Ref Produit and generate a report that contains all Ref Produit with a message for each one: 'The total number of duplicates for Ref Produit: ' || Ref Produit || ' is: ' || ...""

Names Default To Here( 1 );

// Open the data table
dt = Open( "D:/Project JMP/Tables Données/SVI/TableData SVI.jmp", invisible );

// Filter valid IDs: not empty, not equal to "-" or "NOK"
dt_id_tri = dt << Select Where( 
    (:ID != "") & 
    (:ID != "-") & 
    (:ID != "NOK")
);

// Create a new table with the columns Ref Produit, Baie, ID
dt_id_tri = dt << Subset( 
    All rows, 
    columns( :Ref Produit, :Baie, :ID )
);

// Calculate duplicates for a single Ref Produit
one_ref_produit = "22055";
dt_summary_one_ref = dt_id_tri << Summary( 
    Group( :ID ), 
    Freq( "N" ), 
    Where( :Ref Produit == one_ref_produit )
);

// Filter duplicates where the frequency (Freq) is greater than 1
nb_total_doubl_one_ref = N Row( dt_summary_one_ref << Select Where( :N Rows > 1 ) );
report_single_ref = "The total number of duplicates for Ref Produit: " || one_ref_produit || " is: " || nb_total_doubl_one_ref;
Show( report_single_ref );

// Calculate duplicates for all Ref Produit
refs = dt_id_tri << Get As Matrix( :Ref Produit );
refs = Remove Duplicates( refs );

// Loop through all Ref Produit
For( i = 1, i <= N Items( refs ), i++,
    dt_summary_ref = dt_id_tri << Summary( 
        Group( :ID ), 
        Freq( "N" ), 
        Where( :Ref Produit == refs[i] )
    );
    
    // Filter duplicates where the frequency is greater than 1
    nb_total_doubl = N Row( dt_summary_ref << Select Where( :N Rows > 1 ) );
    report_all_ref = "The total number of duplicates for Ref Produit: " || refs[i] || " is: " || nb_total_doubl;
    Show( report_all_ref );
);


I did get this error : 

/*:

NRow or NCol argument must be a Matrix or Data Table at row 1 in access or evaluation of 'N Row' , Bad Argument( Scriptable[] ), N Row/*###*/(dt_summary_one_ref << Select Where( :N Rows > 1 ))

at line 28 in C:\Users\Script.jsl



Thank you.

1 REPLY 1
jthi
Super User

Re: Bad Argument( Scriptable[] )

dt_summary_ref << Select Where( :N Rows > 1 )

will just select rows, it won't return a list or anything else. You have to get selected rows separately by using << get selected rows or use other method of calculating the row count.

-Jarmo