- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Calculation
Step 1 corresponds to the number 2100 but this number can have a different corresponding operation depending on the objects (Example: object 1 --> number 2100 / operation 62, object 5 --> number 2100 / operation 74)
STEP 1: corresponds to number 2100
Names Default To Here( 1 );
dt = Current Data Table();
dur_cols = Filter Each({col_name}, dt << Get Column Names("String", Continuous),
Starts With(col_name, "durée"));
// for indexing later
num_colnr = Transform Each({col_name}, dur_cols,Word(-1, col_name));
dt << New Column("DUREE ETAPE1", Numeric, Continuous, Format(":jou:hh:m",8), << Set Each Value(
If( :"T"n < 2100 ,
colidx = Loc(dt[Row(), num_colnr] > :"opé"n & (num_colnr < 2100 ) );
If(N Items(colidx) > 0,
val = Sum(dt[Row(), dur_cols[colidx]]);
If(IsMissing(val),
0
,
val
);
,
0
)
,
0
)
));
This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Calculation
dt = Current Data Table();
dur_cols = Filter Each( {col_name}, dt << Get Column Names( "String", Continuous ),
Starts With( col_name, "durée" )
);
num_opé = Filter Each( {col_name}, dt << Get Column Names( "String", Continuous ),
Starts With( col_name, "opé" )
);
// for indexing later
num_colnr = Transform Each( {col_name}, dur_cols, Word( -1, col_name ) );
// Add : Matrix of the index
num_colnr_mt = Matrix( Transform Each( {col_name}, dur_cols, Num( Word( -1, col_name ) ) ) )`;
dt << New Column( "DUREE",Numeric,Continuous,Format( ":jou:hh:m", 8 ),<If( dt[Row(), num_opé ] < :"2100"n,//colidx = Loc(dt[Row(), num_colnr] > :"opé"n & (num_colnr < 2100 ) );colidx = Loc( dt[Row(), num_colnr] >= :"opé"n & (dt[Row(), num_colnr] < :"2100"n) ); // ChangedIf( N Items( colidx ) > 0,val = Sum( dt[Row(), dur_cols[colidx]] );If( Is Missing( val ),0,val);,0);,0)));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Calcul
Hi @hcarr01,
I'm not sure I understand your request correctly, but how about the following script?
Names Default To Here( 1 );
dt = Current Data Table();
dur_cols = Filter Each( {col_name}, dt << Get Column Names( "String", Continuous ),
Starts With( col_name, "durée" )
);
// for indexing later
num_colnr = Transform Each( {col_name}, dur_cols, Word( -1, col_name ) );
// Add : Matrix of the index
num_colnr_mt = Matrix( Transform Each( {col_name}, dur_cols, Num( Word( -1, col_name ) ) ) )`;
dt << New Column( "DUREE ETAPE1",
Numeric,
Continuous,
Format( ":jou:hh:m", 8 ),
<<Set Each Value(
If( :"T"n < 2100,
//colidx = Loc(dt[Row(), num_colnr] > :"opé"n & (num_colnr < 2100 ) );
colidx = Loc( dt[Row(), num_colnr] >= :"opé"n & (num_colnr_mt < 2100) ); // Changed
If( N Items( colidx ) > 0,
val = Sum( dt[Row(), dur_cols[colidx]] );
If( Is Missing( val ),
0,
val
);
,
0
);
,
0
)
)
);
If you want to calculate the following code, you need to use matrix.
"num_colnr < 2100"
I hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Calculation
This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Calcul
Hi @hcarr01 ,
Thank you for your response. Can I check my understanding?
Example on the second line:
Operation in progress: 60 (number in column "opé")
Operation corresponding to number 2100 -> 62 (in variable T and opé)
So make the sum of the number corresponding to operation 60, therefore number 1749 (find number 60 in column 1500, 1749, 2100 or 2500).
Therefore "Duration of step" = "Durée 1749" = 45
Example on the third row:
Operation in progress: 62 (number in the "opé" column)
Operation corresponding to the number 2100 -> 62
So make the sum of the number corresponding to operation 62, therefore number 2100.
Therefore, "Step duration" = 0 (because the current operation is greater than or equal to the operation corresponding to number 2100).
In your question you described as follows.
"Step 1 corresponds to number 2100, but this number can have a different corresponding operation depending on the objects (example: object 1 --> number 2100 / operation 62, object 5 --> number 2100 / operation 74)".
What does object 5 look like? Can you give us an example?
If my understanding is not correct, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Calculation
dt = Current Data Table();
dur_cols = Filter Each( {col_name}, dt << Get Column Names( "String", Continuous ),
Starts With( col_name, "durée" )
);
num_opé = Filter Each( {col_name}, dt << Get Column Names( "String", Continuous ),
Starts With( col_name, "opé" )
);
// for indexing later
num_colnr = Transform Each( {col_name}, dur_cols, Word( -1, col_name ) );
// Add : Matrix of the index
num_colnr_mt = Matrix( Transform Each( {col_name}, dur_cols, Num( Word( -1, col_name ) ) ) )`;
dt << New Column( "DUREE",Numeric,Continuous,Format( ":jou:hh:m", 8 ),<If( dt[Row(), num_opé ] < :"2100"n,//colidx = Loc(dt[Row(), num_colnr] > :"opé"n & (num_colnr < 2100 ) );colidx = Loc( dt[Row(), num_colnr] >= :"opé"n & (dt[Row(), num_colnr] < :"2100"n) ); // ChangedIf( N Items( colidx ) > 0,val = Sum( dt[Row(), dur_cols[colidx]] );If( Is Missing( val ),0,val);,0);,0)));
This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Calcul
I'm glad you were able to solve the problem yourself.