Help:Table format
From semantic-mediawiki.org
The result formats table and broadtable are used to format query results as tables. The format table is the default way of formatting query results for all queries that have one or more additional printout statements.
Example
{{#ask: [[Category:City]] [[located in::Germany]]
| ?population
| ?area#km² = Size in km²
}}
This produces the following output:
| Population | Size in km² | |
|---|---|---|
| Berlin | 33914073,391,407 | 891690000891.69 km²891,690,000 m² 89,169 ha 344.283 miles² 1.74817e-6 earths |
| Hannover | 515772515,772 | |
| Munich | 12596771,259,677 | 310460000310.46 km²310,460,000 m² 31,046 ha 119.869 miles² 6.0866e-7 earths |
| Stuttgart | 595452595,452 | 207458047.638207.458 km²207,458,047.638 m² 20,745.805 ha 80.1 miles² 4.06724e-7 earths |
The broadtable merely stretches the table to 100% of the available width:
{{#ask: [[Category:City]] [[located in::Germany]]
| ?population
| ?area#km² = Size in km²
| format=broadtable
}}
This produces the following output:
| Population | Size in km² | |
|---|---|---|
| Berlin | 33914073,391,407 | 891690000891.69 km²891,690,000 m² 89,169 ha 344.283 miles² 1.74817e-6 earths |
| Hannover | 515772515,772 | |
| Munich | 12596771,259,677 | 310460000310.46 km²310,460,000 m² 31,046 ha 119.869 miles² 6.0866e-7 earths |
| Stuttgart | 595452595,452 | 207458047.638207.458 km²207,458,047.638 m² 20,745.805 ha 80.1 miles² 4.06724e-7 earths |
Parameters
There are no inline query parameters specific to the table or broadtable formats. The parameter headers=hide is specifically useful for hiding the header of tables (in most other cases, it is enough to use empty printout labels to hide the titles of printout statements).
Remarks
Tables have a special feature for sorting their contents by any of the columns in the table. See Help:Selecting results for general comments on sorting and a comparion to the wiki's query result sorting. Browsers without JavaScript enabled will not see the buttons for sorting at all.
SMW formats its tables with CSS class="smwtable". Using this class on other tables to achieve similar formatting is possible, but will only work reliably if the according page contains a query or other SMW specific elements. In other cases, the SMW style files will not be loaded at all, so the style is not available.

