cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-801984%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%EC%9E%98%EB%AA%BB%EB%90%9C%20%EC%9D%B8%EC%88%98(Scriptable%5B%5D)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-801984%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20everyone%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20a%20problem%20with%20my%20script%2C%20i%20want%20to%20do%20a%20study%20%3A%3CBR%20%2F%3EIt's%20about%20filtering%20the%20IDs%2C%20avoiding%20IDs%20that%20are%20empty%2C%20equal%20to%20%22-%22%20or%20equal%20to%20%22NOK%22.%20Then%2C%20these%20filtered%20IDs%20should%20be%20placed%20in%20a%20new%20table%20called%20%3CCODE%3Edt_id_tri%3C%2FCODE%3E%20with%20the%20following%20columns%3A%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%2C%20%3CCODE%3EBaie%3C%2FCODE%3E%2C%20and%20%3CCODE%3EID%3C%2FCODE%3E.%20After%20that%2C%20take%20a%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%20from%20the%20dataset%20and%20calculate%20the%20total%20number%20of%20duplicates%20(%3CCODE%3Enb_total_doubl%3C%2FCODE%3E)%20for%20that%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%2C%20and%20include%20it%20in%20a%20JMP%20report%20with%20the%20message%3A%20'The%20total%20number%20of%20duplicates%20for%20Ref%20Produit%3A%20'%20%7C%7C%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%20%7C%7C%20'%20is%3A%20'%20%7C%7C%20...%3CBR%20%2F%3EFor%20the%20second%20part%2C%20do%20the%20same%20for%20all%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%20and%20generate%20a%20report%20that%20contains%20all%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%20with%20a%20message%20for%20each%20one%3A%20'The%20total%20number%20of%20duplicates%20for%20Ref%20Produit%3A%20'%20%7C%7C%20%3CCODE%3ERef%20Produit%3C%2FCODE%3E%20%7C%7C%20'%20is%3A%20'%20%7C%7C%20...%22%22%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0A%2F%2F%20Open%20the%20data%20table%0Adt%20%3D%20Open(%20%22D%3A%2FProject%20JMP%2FTables%20Donn%C3%A9es%2FSVI%2FTableData%20SVI.jmp%22%2C%20invisible%20)%3B%0A%0A%2F%2F%20Filter%20valid%20IDs%3A%20not%20empty%2C%20not%20equal%20to%20%22-%22%20or%20%22NOK%22%0Adt_id_tri%20%3D%20dt%20%26lt%3B%26lt%3B%20Select%20Where(%20%0A%20%20%20%20(%3AID%20!%3D%20%22%22)%20%26amp%3B%20%0A%20%20%20%20(%3AID%20!%3D%20%22-%22)%20%26amp%3B%20%0A%20%20%20%20(%3AID%20!%3D%20%22NOK%22)%0A)%3B%0A%0A%2F%2F%20Create%20a%20new%20table%20with%20the%20columns%20Ref%20Produit%2C%20Baie%2C%20ID%0Adt_id_tri%20%3D%20dt%20%26lt%3B%26lt%3B%20Subset(%20%0A%20%20%20%20All%20rows%2C%20%0A%20%20%20%20columns(%20%3ARef%20Produit%2C%20%3ABaie%2C%20%3AID%20)%0A)%3B%0A%0A%2F%2F%20Calculate%20duplicates%20for%20a%20single%20Ref%20Produit%0Aone_ref_produit%20%3D%20%2222055%22%3B%0Adt_summary_one_ref%20%3D%20dt_id_tri%20%26lt%3B%26lt%3B%20Summary(%20%0A%20%20%20%20Group(%20%3AID%20)%2C%20%0A%20%20%20%20Freq(%20%22N%22%20)%2C%20%0A%20%20%20%20Where(%20%3ARef%20Produit%20%3D%3D%20one_ref_produit%20)%0A)%3B%0A%0A%2F%2F%20Filter%20duplicates%20where%20the%20frequency%20(Freq)%20is%20greater%20than%201%0Anb_total_doubl_one_ref%20%3D%20N%20Row(%20dt_summary_one_ref%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AN%20Rows%20%26gt%3B%201%20)%20)%3B%0Areport_single_ref%20%3D%20%22The%20total%20number%20of%20duplicates%20for%20Ref%20Produit%3A%20%22%20%7C%7C%20one_ref_produit%20%7C%7C%20%22%20is%3A%20%22%20%7C%7C%20nb_total_doubl_one_ref%3B%0AShow(%20report_single_ref%20)%3B%0A%0A%2F%2F%20Calculate%20duplicates%20for%20all%20Ref%20Produit%0Arefs%20%3D%20dt_id_tri%20%26lt%3B%26lt%3B%20Get%20As%20Matrix(%20%3ARef%20Produit%20)%3B%0Arefs%20%3D%20Remove%20Duplicates(%20refs%20)%3B%0A%0A%2F%2F%20Loop%20through%20all%20Ref%20Produit%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(%20refs%20)%2C%20i%2B%2B%2C%0A%20%20%20%20dt_summary_ref%20%3D%20dt_id_tri%20%26lt%3B%26lt%3B%20Summary(%20%0A%20%20%20%20%20%20%20%20Group(%20%3AID%20)%2C%20%0A%20%20%20%20%20%20%20%20Freq(%20%22N%22%20)%2C%20%0A%20%20%20%20%20%20%20%20Where(%20%3ARef%20Produit%20%3D%3D%20refs%5Bi%5D%20)%0A%20%20%20%20)%3B%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20Filter%20duplicates%20where%20the%20frequency%20is%20greater%20than%201%0A%20%20%20%20nb_total_doubl%20%3D%20N%20Row(%20dt_summary_ref%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AN%20Rows%20%26gt%3B%201%20)%20)%3B%0A%20%20%20%20report_all_ref%20%3D%20%22The%20total%20number%20of%20duplicates%20for%20Ref%20Produit%3A%20%22%20%7C%7C%20refs%5Bi%5D%20%7C%7C%20%22%20is%3A%20%22%20%7C%7C%20nb_total_doubl%3B%0A%20%20%20%20Show(%20report_all_ref%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CBR%20%2F%3E%EB%82%98%EB%8A%94%20%EC%9D%B4%20%EC%98%A4%EB%A5%98%EB%A5%BC%20%EC%96%BB%EC%97%88%EC%8A%B5%EB%8B%88%EB%8B%A4%20%3A%3C%2FP%3E%3CP%3E%2F*%3A%3C%2FP%3E%3CP%3ENRow%20%EB%98%90%EB%8A%94%20NCol%20%EC%9D%B8%EC%88%98%EB%8A%94%20'N%20Row'%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%95%A1%EC%84%B8%EC%8A%A4%20%EB%98%90%EB%8A%94%20%ED%8F%89%EA%B0%80%EC%97%90%EC%84%9C%20%ED%96%89%201%EC%97%90%20%EC%9E%88%EB%8A%94%20%ED%96%89%EB%A0%AC%20%EB%98%90%EB%8A%94%20%EB%8D%B0%EC%9D%B4%ED%84%B0%20%ED%85%8C%EC%9D%B4%EB%B8%94%EC%9D%B4%EC%96%B4%EC%95%BC%20%ED%95%A9%EB%8B%88%EB%8B%A4.%20%EC%9E%98%EB%AA%BB%EB%90%9C%20%EC%9D%B8%EC%88%98(Scriptable%5B%5D)%2C%20N%20Row%2F*%23%23%23*%2F(dt_summary_one_ref%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AN%20Rows%20%26gt%3B%201%20))%3C%2FP%3E%3CP%3EC%3A%5CUsers%5CScript.jsl%EC%9D%98%2028%EB%B2%88%EC%A7%B8%20%EC%A4%84%EC%97%90%EC%84%9C%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%EA%B0%90%EC%82%AC%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-801984%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%EA%B3%A0%EA%B8%89%20%ED%86%B5%EA%B3%84%20%EB%AA%A8%EB%8D%B8%EB%A7%81%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%EB%8D%B0%EC%9D%B4%ED%84%B0%20%EC%A0%91%EA%B7%BC%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%ED%92%88%EC%A7%88%20%EB%B0%8F%20%EA%B3%B5%EC%A0%95%20%EC%97%94%EC%A7%80%EB%8B%88%EC%96%B4%EB%A7%81%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%EC%9C%88%EB%8F%84%EC%9A%B0%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-801994%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%EC%9E%98%EB%AA%BB%EB%90%9C%20%EC%9D%B8%EC%88%98(Scriptable%5B%5D)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-801994%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt_summary_ref%20%26lt%3B%26lt%3B%20Select%20Where(%20%3AN%20Rows%20%26gt%3B%201%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%ED%96%89%EB%A7%8C%20%EC%84%A0%ED%83%9D%ED%95%98%EA%B3%A0%2C%20%EB%AA%A9%EB%A1%9D%EC%9D%B4%EB%82%98%20%EB%8B%A4%EB%A5%B8%20%EA%B2%83%EC%9D%80%20%EB%B0%98%ED%99%98%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%26lt%3B%26lt%3B%20get%20selected%20rows%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EC%84%A0%ED%83%9D%ED%95%9C%20%ED%96%89%EC%9D%84%20%EB%94%B0%EB%A1%9C%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B1%B0%EB%82%98%20%ED%96%89%20%EC%88%98%EB%A5%BC%20%EA%B3%84%EC%82%B0%ED%95%98%EB%8A%94%20%EB%8B%A4%EB%A5%B8%20%EB%B0%A9%EB%B2%95%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%B4%EC%95%BC%20%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3C%2FLINGO-BODY%3E
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