PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Merge data from view or datafile
Merge data from view or datafile
Iniciado por guest, 28,oct. 2015 18:40 - 7 respuestas
Publicado el 28,octubre 2015 - 18:40
Hello,

In the picture below a view from a data file, how can i make a sum of the "Totaal tijd" from the same "Medewerker"?
So the second and the third row wil have both a "totaal tijd" of 3,00

[attachment 1747 Knipsel.JPG]

Thanks,
SB
Publicado el 29,octubre 2015 - 07:19
Hello Sammy

You can but it is not a perfect solution.
You can put breaks in the table - e.g. on Medewerker and you can generate sub totals for the break. The problem is that you have to put the subtotal value into a static and you can't link the static to a column so if the table is expanded or shrunk the static does not move with the column

It would work ok for you as you only have one column to add up.
Have a look at Table Break in the help

Regards
Al
Publicado el 29,octubre 2015 - 08:04
Hello Sammy,

Looks like time Management :)

If you just want to Show the result in a table, Report, ... (not changing the data files), I do it this way:
Define a new table column (eg. tijdsum). Then make a programmed Loop through all table lines and do the Summation, writing the result in the new column.

Then you may hide the original (total tijd) or Show both of them or what you like to do.
And also, I prefer to Show the result only in one line (maybe the first or last for each mederworker) to prevent confusion.

Regards
Erik
Publicado el 29,octubre 2015 - 11:28
Erik,

You are right, it`s time managment :)

Thats exact what i want, show the result in a new column and then only in the first line for each "medewerker".
But what is the best way to create such a loop?
Publicado el 29,octubre 2015 - 13:09
Hello Sammy,

U can make new SQL Query, make it with sum of Totaal tijd and group by Medewerker, that way you could fill new column in table by programming from results of Query.

Best regards,

Ivan V.
Publicado el 29,octubre 2015 - 13:56
Hi Sammy,

i am doing something like this:

sum is int = 0
temp_mederworker = table[1].mederworker
//
for i=1 to tablecount(...)
if temp_mederworker = table.mederworker
sum += table.tijd
else // mederworker has changed
table[i-1].sumtijd = sum
sum = table.tijd
temp_mederworker = table.mederworker
end
end
// take care if last mederworker
table[i-1].sumtijd = sum

not tested, may be small bugs inside, but principle is used by me often.
Writes the sum at the last line of each mederworker.
If sum should be at the first line of mederworker, just invers the Loop:
for tablecount(..) to 1 step -1
and adjust Initial Settings,...

Hope this helps.

Erik
Publicado el 29,octubre 2015 - 14:12
HI,

any my text got formatted some weird.

Table ... should always be like table

Erik
Publicado el 29,octubre 2015 - 17:08
[attachment 1749 Knipsel.JPG]

Now i dit it with a break because the looper works not as i want.

Thanks all.