0

I am using semantic-mediawiki to store different diaries, i.e. workrelated, private things, etc. in subobjects like these:

{{#subobject:
 |Has date = 2020-04-08
 |Has log = work-log
 |has agenda = 
* Work related task done
}}

{{#subobject:
 |Has date = 2020-04-08
 |Has log = private-log
 |has agenda = 
* Something very interesting happened today
}}

{{#subobject:
 |Has date = 2020-04-07
 |Has log = private-log
 |has agenda = 
* Today nothing happened
}}

All this information can be queried with an #ask query like this, summarizing all the entries from all the log types:

{{#ask:
 [[Has log::+]]
 |?Has date =Date
 |?Has agenda =Agenda
 |format=broadtable
 |sort=Has date
 |order=desc
 |mainlabel=-
}}

When doing it like this, in the resulting table I get one row per entry, and thus separate entries for activities that happened on the same day, like this:

Date        Agenda
--------------------------------------------------------
2020-04-08  * Work related task done
--------------------------------------------------------
2020-04-08  * Something very interesting happened today
--------------------------------------------------------
2020-04-07  * Today nothing happened

Would it be possible to group these results by their date in the output, similar to the SQL GROUP BY statement, so that I would get something like this?:

Date        Agenda
--------------------------------------------------------
2020-04-08  * Work related task done
            * Something very interesting happened today
--------------------------------------------------------
2020-04-07  * Today nothing happened

Thank you!

Wald3n
  • 133
  • 1
  • 10

1 Answers1

1

A group by clause is not possible in SMW, but by using the template format for results you can achieve the look you are trying to get.

FO-nTTaX
  • 601
  • 5
  • 11
  • Thank you. I was thinking in the same direction and would like that very much. However, I always end up with the same problem of grouping when thinking about a way to implement that. Does anyone have an idea how to write such a template? – Wald3n Apr 08 '20 at 15:33
  • 2
    You can combine SMW with Extension:Variables to know if the next lines date is the same as the last lines date, and only if it is different you start a new row in your table. If you get your datapoints from SMW ordered by date, that would work. – FO-nTTaX Apr 08 '20 at 18:25
  • I strongly advise you to use `arrays` extension in conjuction with SMW. This can easily be achieved this way. – IRA1777 Apr 21 '20 at 09:30