Semanticmediawiki: Order number as a printout in queries

Created on 29 Mar 2021  路  2Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

It would be convenient, if a query could have the order number (in the selected sort order) displayed as a printout. For instance, if I wanted to display a table about the the world TOP50 countries according to population, it would be nice to have the order of each country (1-50) displayed in the first column. In a template, the order number could be used with a parserfunctions to change color or symbol according to rank.

Maybe the #ask query could have a printout statement "|#" (or whatever) for the order number similar as "|?" is for the mainlabels?

So a query similar to this:

{{#ask:
  [[Category:Country]]
    |#=Rank
    |?=Country
    |?Population
    |sort=Population
    |order=desc
    |limit=3
}}

Would output a table like this:

Rank    Country Population
1   China   1,439,323,776
2   India   1,380,004,385
3   USA     331,002,651

The order number should always be in relation to the query sort, so if an offset is specified, the order number of the first item would be offset+1.

question

All 2 comments

Have a look at this documentation The offset is however not considered. I believe it this case you would have to annotate the ranking.

Thanks! I had missed that while browsing through the documentation. I actually don't need the offset, so this is just perfect for me.

Was this page helpful?
0 / 5 - 0 ratings