I'm currently writing some CAML Query for a QueryOverride in one of my Content Query Web Parts as I'm in need of multiple "Sort by" fields.

My issue is that one of the additional fields that I need sorting on may contain null values which make the query ignore the rows which has a null value and only performs the sort on rows which has a legitimate value.

My CAML Query so far

    <FieldRef Name="ArticleStartDate" Ascending="False" />
    <FieldRef Name="ArticlePriority" Ascending="True" />
            <FieldRef Name="FilterMM" />
            <Value Type="TaxonomyFieldType">Company news</Value>
                <FieldRef Name="ArticleStartDate" />
                <Value Type="DateTime"><Today /></Value>
                <FieldRef Name="_EndDate" />
                <Value Type="DateTime"><Today /></Value>

ArticlePriority is the troublemaker, as not all news have a priority set as they are less important than others which has priority 1,2,3 etc. meaning they should at all times be AFTER the ones with set priorities.

I tried adding Nullable="True" to it as I thought that might help but no luck.

Any ideas?

1 Answer 1


If ArticlePriority is a choice column then null values will be sorted before the ones with values.

One solution could be to create a hidden calculated column with the formular something like =IF(ArticlePriority=0,9999,ArticlePriority) and then order by that column

  • It's unfortunately not a choice column, it's a number column as the priorities have to be unique values in order to prevent multiple articles having the same priority.
    – user2536
    Jan 10, 2013 at 13:40
  • 1
    Then use the formular =IF(ISNUMBER(ArticlePriority),ArticlePriority,999999) Jan 10, 2013 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.