Différences entre les versions de « Aggregating numbers »

De Semantic MediaWiki - Sandbox

(chg)
(chg)
 
(4 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
== Sum for subobject embedded numbers ==
+
Refs: http://wikimedia.7.x6.nabble.com/SMW-Property-Ask-Same-property-multiple-times-on-same-page-tc5073446.html
 +
== Storing values ==
 +
<pre>
 +
{{#subobject:
 +
|Is row={{#counter: example }} // make the subobject unique
 +
|Has page={{FULLPAGENAME}} // provide an identical reference
 +
|Has text=first // some text
 +
|Has number=1 // some number
 +
}}
 +
</pre>
 
<div style="display: none">
 
<div style="display: none">
 
{{#subobject:
 
{{#subobject:
  |Has text={{#counter: {{FULLPAGENAME}} }}
+
  |Is row={{#counter: example }}
 
  |Has page={{FULLPAGENAME}}
 
  |Has page={{FULLPAGENAME}}
 +
|Has text=first
 
  |Has number=1
 
  |Has number=1
 
}}
 
}}
 
{{#subobject:
 
{{#subobject:
  |Has text={{#counter: {{FULLPAGENAME}} }}
+
  |Is row={{#counter: example }}
 
  |Has page={{FULLPAGENAME}}
 
  |Has page={{FULLPAGENAME}}
 +
|Has text=second
 
  |Has number=2
 
  |Has number=2
 
}}
 
}}
 
{{#subobject:
 
{{#subobject:
  |Has text={{#counter: {{FULLPAGENAME}} }}
+
  |Is row={{#counter: example }}
 
  |Has page={{FULLPAGENAME}}
 
  |Has page={{FULLPAGENAME}}
 +
|Has text=third
 
  |Has number=1
 
  |Has number=1
 
}}
 
}}
 
{{#subobject:
 
{{#subobject:
  |Has text={{#counter: {{FULLPAGENAME}} }}
+
  |Is row={{#counter: example }}
 
  |Has page={{FULLPAGENAME}}
 
  |Has page={{FULLPAGENAME}}
 +
|Has text=fourth
 
  |Has number=2
 
  |Has number=2
 
}}
 
}}
 
</div>
 
</div>
 +
== Querying values ==
 
<pre>
 
<pre>
 
{{#ask:
 
{{#ask:
Ligne 31 : Ligne 45 :
 
}}
 
}}
 
</pre>
 
</pre>
 +
== Result ==
 
;Table
 
;Table
 
{{#ask:
 
{{#ask:

Dernière version du 29 mars 2017 à 23:02

Refs: http://wikimedia.7.x6.nabble.com/SMW-Property-Ask-Same-property-multiple-times-on-same-page-tc5073446.html

Storing values

{{#subobject:
 |Is row={{#counter: example }} // make the subobject unique
 |Has page={{FULLPAGENAME}} // provide an identical reference
 |Has text=first // some text
 |Has number=1 // some number
}}



Querying values

{{#ask:
 [[Has page::{{FULLPAGENAME}}]]
 [[Has number::+]]
 |?Has text=Name
 |?Has number=Value
 |mainlabel=-
}}

Result

Table
NameValue
first1
third1
second2
fourth2
Total

6

Count

4

Les cookies nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de cookies.