semantic-mediawiki

Display multiple conversions of quantity in #ask query


Is it possible to display a Quantity in multiple units at the same time in #ask query.

Say I have a property [[Has length]]

[[Has type::Quantity]]
[[Display units::in,cm]]
[[Corresponds to::1 in]]
[[Corresponds to::2.54 cm]]

And then I have a query like

{{#ask: [Category:Cables]
|?Has length
|format=table
}}

I like to be able to display the length in 'in' and 'cm' say something like

Cable A | 12 in (30 cm)
Cable B | 6 in (15 cm)

I tried |?Has length#in (cm) but that didn't work


Solution

  • {{#ask: [[Category:Cables]]
    |?Has length#in
    |?Has length#cm
    |format=table
    }}
    

    A similar example (length in meters and kilometers): https://traditio.wiki/Project:Test80.

    Note the double brackets.

    If you want to display different units of measurement in the same column, you have to use format=template and a corresponfing template like

    {{!}}-
    {{!}} {{{2|}}} ({{{3|}}})