Tags:
create new tag
view all tags

SID-01449: Sum across Tables on different Topics

Status: Answered Answered TWiki version: 5.0.2 Perl version:
Category: SpreadSheetPlugin Server OS: Last update: 14 years ago

Hi,

This is a very specific use case that I can't seem to find any answers for.

If I have the same table (same columns/same rows/diff data) on different topics, is there a way to sum up specific cells across multiple topics?

For example:
Topic 1("Bananas") has Table:
Banana Count -> 3
Topic 2 ("Apples") has Table:
Apple Count -> 4

If I make a new topic ("Fruits"), how do I make a new table that combines the 2? Fruit Count -> 7

I don't mind if the table has the same table structure and everything too.

-- TWikiGuest - 2012-04-16

Discussion and Answer

Two options:

1. INCLUDE those topics, and apply the CALC over all topics. Example at SpreadSheetRollupTest

2. Do a SEARCH that identifies all topics with the tables. Sum up the total using a spreadsheet variable. Untested code using TWikiForms field named "Count" for easy query (instead of table) :

%CALC{$SET(total, 0)}%
%SEARCH{
  "string that identifies your fruit topics"
  nonoise="on"
  format="$percntCALC{$SETM(total, +$formfield(Count))}$percnt"
  separator=" "
}%
Total:
%CALC{$GET(total)}%

If you have a table instead of a TWiki form you need to apply a regular expression to get the number. Assuming your table looks like:

Count: 3
You can apply this (again untested) :
  multiple="on"
  format="$percntCALC{$SETM(total, +$pattern(^\| Count: \| *([0-9]+) *\|.*))}$percnt"

See also VarSEARCH, QuerySearch, SpreadSheetPlugin, RegularExpression, How to Create a TWiki Application

-- PeterThoeny - 2012-04-16

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Sum across Tables on different Topics
SupportCategory SpreadSheetPlugin
TWiki version 5.0.2
Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2012-04-16 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.