report-evaluation from list-option data from scaffolding subpages

  • 1
  • Question
  • Updated 2 years ago
  • (Edited)
Hi @ll,

I'm having a scaffolding page where I do my data inputs:

{list-data:name:number1}
{list-option:value=3:label=three:sort-value=1}
{list-option:value=5:label=five:sort-value=2}
{list-data}
{list-data:name:number2}
{list-option:value=3:label=three:sort-value=1}
{list-option:value=5:label=five:sort-value=2}
{list-data}

Input: number1=3 number2=5
on the same page I can sum these values of "number1" and "number2" with:
{report-table}
{local-reporter:key=@self}
{report-variable:name=number1:value=0%data:number1:default=0}
{report-variable:name=number2:value=0%data:number2:default=0}
{report-column:title=Sum}
{report-eval:name=sum:default=0:format=0.00}
{(%variable:number1%)+(%variable:number2%)}
{report-eval}
{report-column}
{report-table}
Output: 8

but if I want this "sum" on a parrent overview-page this is not possible (due to "The value is only stored temporarily. It can't be accessed from another page, for example. [https://docs.servicerocket.com/displa...]
I tried the same report structure to calculate the sum but with a different locator Page:children
{report-table:injectd:true}
{local-reporter:key=page:children}
{report-variable:name=number1:value=0%data:number1:default=0}
{report-variable:name=number2:value=0%data:number2:default=0}
{report-column:title=number1}
{report-info:key=data:number1}
{report-column}
{report-column:title=number1}
{report-info:key=data:number1}
{report-column}
{report-column:title=Sum}
{report-eval:name=sum:default=0:format=0.00}
{%variable:number1%+%variable:number2%}
{report-eval}
{report-column}
{report-table}
Output:
||number1||number2||sum||
|3 | 5 | 0.00|
How can I achieve the calculation on the "overview-page" ?

Confluence 5.8.9
Scaffolding / Reporting Version - not sure about the version
Photo of André

André

  • 7 Posts
  • 0 Reply Likes

Posted 2 years ago

  • 1
Photo of Suresh Mathusuthanan

Suresh Mathusuthanan, Alum

  • 117 Posts
  • 9 Reply Likes
Hi Andre,

If my understanding is correct, I can see that you want to calculate the sum on a different page.

Can you please confirm / explain further on what you're trying to achieve ? I will be more than happy to assist you.

Thank you.

Best regards,
Suresh
Photo of André

André

  • 7 Posts
  • 0 Reply Likes
Hi Suresh
I have subpages where diferent values are collected (number1 + number2) on the subpage this calculation works fine.
But I need this sum not only on the subpages rather than on the overview page.

Background:
I'm dooing an evaluation and the subpages represent the evaluated tools which are evaluated with list-data fields and to sum the the values I only need the summed values on the overview page to compare the results.
(Edited)
Photo of Suresh Mathusuthanan

Suresh Mathusuthanan, Alum

  • 117 Posts
  • 9 Reply Likes
Hi Andre,

Thanks for the clarification.

I have recreated your scaffolding and report structure based on your clarification. Can you try out the following storage format. 

Overview page :

<ac:structured-macro ac:macro-id="9308e594-27ec-43aa-8c57-40b132d34f17" ac:name="report-table" ac:schema-version="1"><ac:rich-text-body><ac:structured-macro ac:macro-id="f21d64f8-ae7f-4637-9d7c-e31384c101e6" ac:name="local-reporter" ac:schema-version="1"><ac:parameter ac:name="">page:children</ac:parameter><ac:rich-text-body><p>&nbsp;</p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="d408de11-ca6a-44a9-ba9c-ec047a7a4c33" ac:name="report-column" ac:schema-version="1"><ac:parameter ac:name="title">Sum</ac:parameter><ac:rich-text-body><p><ac:structured-macro ac:macro-id="29fdc758-47d0-4a70-b243-6bb8c7b9489e" ac:name="report-eval" ac:schema-version="1"><ac:parameter ac:name="default">0</ac:parameter><ac:parameter ac:name="format">0.00</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:parameter ac:name="">sum2</ac:parameter><ac:plain-text-body><![CDATA[((%data:number1 > collection:first%)+(%data:number2 > collection:first%))]]></ac:plain-text-body></ac:structured-macro></p></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro>
Sub-page :

<p><ac:structured-macro ac:macro-id="958dd213-fb15-47d8-82f4-82b8a6b692ce" ac:name="list-data" ac:schema-version="1"><ac:parameter ac:name="name">number1</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body><ac:structured-macro ac:macro-id="208a8c24-feda-47b7-924a-b1ac56fe1d0d" ac:name="list-option" ac:schema-version="1"><ac:parameter ac:name="sortValue">1</ac:parameter><ac:parameter ac:name="label">three</ac:parameter><ac:parameter ac:name="value">3</ac:parameter><ac:rich-text-body>&nbsp;</ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="b9c2a78a-f4e5-401d-a818-2018da5d6ea0" ac:name="list-option" ac:schema-version="1"><ac:parameter ac:name="sortValue">2</ac:parameter><ac:parameter ac:name="label">five</ac:parameter><ac:parameter ac:name="value">5</ac:parameter><ac:rich-text-body>&nbsp;</ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="a755ab27-2069-43ef-9a28-fbc09b4a5db4" ac:name="list-data" ac:schema-version="1"><ac:parameter ac:name="name">number2</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body><ac:structured-macro ac:macro-id="9748b961-2914-4bbc-afd6-9376db937997" ac:name="list-option" ac:schema-version="1"><ac:parameter ac:name="sortValue">1</ac:parameter><ac:parameter ac:name="label">three</ac:parameter><ac:parameter ac:name="value">3</ac:parameter><ac:rich-text-body>&nbsp;</ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="d2c628bb-5b33-4424-95c2-4ccff3a5def9" ac:name="list-option" ac:schema-version="1"><ac:parameter ac:name="sortValue">2</ac:parameter><ac:parameter ac:name="label">five</ac:parameter><ac:parameter ac:name="value">5</ac:parameter><ac:rich-text-body>&nbsp;</ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro></p>
Photo of André

André

  • 7 Posts
  • 0 Reply Likes
Hi Suresh,

that works as expected - thank you.

But there's one more thing :-)
If I calculate with the data direct I have no default value.
Problem: if a field is empty I get the error
Misplaced right parenthesis with no matching left parenthesis.
wich is caused by empty field.

If I do it with an report variable I can define a default value "0"

So I tried to do a report-variable
{report-variable:name=number1|value=0%data:number1> collection:first%|default=0}
into this sample output
{report-table}
{report-variable:name=number1|value=0%data:number1> collection:first%|default=0}
{report-column}
{report-info:key=data:number1}
{report-column}
{report-column}
{report-info:key=variable:number1}
{report-column}
{report-table}
The value for data:number1 = 3 (correct value)
The value for variable:number1 = 0 (incorrect value)

Why can't I use the variables with the keychain provided by you.

Thanks in advance

Kind regards André
Photo of Suresh Mathusuthanan

Suresh Mathusuthanan, Alum

  • 117 Posts
  • 9 Reply Likes
Hi André,

If my understanding is correct, you're looking to define a temporary variable using report variable to hold data in the current report context. Do clarify further if I'm wrong.

I have made some changes to your report structure and I have attached a screenshot of the report structure to illustrate better on how to achieve a temporary variable using report variable. 

 Can you please try out the following storage format. 



<ac:structured-macro ac:macro-id="c92acefc-41c2-49af-9d55-ed7fe4068d86" ac:name="report-table" ac:schema-version="1"><ac:rich-text-body><ac:structured-macro ac:macro-id="0ee4c1fa-3456-4fe0-8198-bf3bfbb94d40" ac:name="local-reporter" ac:schema-version="1"><ac:parameter ac:name="">page:children</ac:parameter><ac:rich-text-body><p>&nbsp;</p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="b8cddff9-489b-4112-9a89-135ea8665b85" ac:name="report-column" ac:schema-version="1"><ac:parameter ac:name="title">Sum</ac:parameter><ac:rich-text-body><p><ac:structured-macro ac:macro-id="df76fafb-9162-42b6-a3a2-f59c513c519d" ac:name="report-variable" ac:schema-version="1"><ac:parameter ac:name="default">0</ac:parameter><ac:parameter ac:name="name">number1</ac:parameter><ac:parameter ac:name="value">%data:number1 &gt; collection:first%</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body><p>&nbsp;</p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="e38ac2d3-61cd-4d1b-9b82-0def343d1124" ac:name="report-variable" ac:schema-version="1"><ac:parameter ac:name="default">0</ac:parameter><ac:parameter ac:name="name">number2</ac:parameter><ac:parameter ac:name="value">%data:number2 &gt; collection:first%</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body><p>&nbsp;</p></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:macro-id="d75a0aa9-c824-43de-ae23-c1e93cff061f" ac:name="report-eval" ac:schema-version="1"><ac:parameter ac:name="default">0</ac:parameter><ac:parameter ac:name="format">0.00</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:parameter ac:name="">sum2</ac:parameter><ac:plain-text-body><![CDATA[(%variable:number1% + %variable:number2%)]]></ac:plain-text-body></ac:structured-macro></p></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro>