"sort" option in query does not include results that have no value in sorted field
Hello,
The following query brings up no results (because Begin Date is blank):
{{#ask:[[Category:Market research]] |?ResearchStatus |?ResearchType |?Description |sort=BeginDate }}
But this query brings up all results:
{{#ask:[[Category:Market research]] |?ResearchStatus |?ResearchType |?Description }}
I don't think that it logically follows that a "sort" option should exclude results where sorted field is blank.
Well, if you do not query for a property you cannot sort by it since your printout statement cannot be fulfilled. Somehow you have to pick up the date from the pages/subobjects with the query. See sorting results. So your query should be
{{#ask:[[Category:Market research]] |?ResearchStatus |?ResearchType |?Description |?BeginDate |sort=BeginDate }}
A simple workaround to this is to define, in the template, some default values for the properties of interest if they are not already set. ie:
{{#if: {{{ArgIwant|}}}||[[PropIneed::SomeDefaultValue]]}}
It's more elegant to do it where it's actually printing, but this has overcome the whole 'sort' issue any time I've needed it. Though, it assumes all the articles call some templates to which you could do this.