cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
View Original Published Thread

Add cells

hcarr01
Level VI

Hello, how could I do for: on a column add values when consecutive terms are equal and leave the initial values when the consecutive terms are different?

Ex:

 

undefined

 

 

This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User


Re: Additionner des cellules

Not exactly sure how you would like your data to look, but using Dif (or Lag) in formula should work

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(7),
	Compress File When Saved(1),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 1, 2, 3, 4, 4, 4, 5])
	)
);

dt << New Column("Col", Numeric, Continuous, Formula(
	As Constant(val = :Column 1);
	If(Dif(:Column 1) == 0,
		val += :Column 1
	,
		val = :Column 1;
	);
	val;
));
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User


Re: Additionner des cellules

Not exactly sure how you would like your data to look, but using Dif (or Lag) in formula should work

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(7),
	Compress File When Saved(1),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 1, 2, 3, 4, 4, 4, 5])
	)
);

dt << New Column("Col", Numeric, Continuous, Formula(
	As Constant(val = :Column 1);
	If(Dif(:Column 1) == 0,
		val += :Column 1
	,
		val = :Column 1;
	);
	val;
));
-Jarmo
hcarr01
Level VI

Re: Add cells

 

thank you for your reply @jthi !

This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .