Code Monkey home page Code Monkey logo

Comments (2)

bwanders avatar bwanders commented on June 12, 2024

You are correct that the results will seem a bit funny (especially when one is used to SQL queries): all results in strata act like sets in that only unique results are reckoned. In this case, what happens is that the table query projects ?who and ?beans, which leads to the following result set:

(?who=peter, ?beans=1)
(?who=peter, ?beans=2)

Note that both the tuesday and wednesday entries result in the same (peter, 2) result, and are therefore not both present in the result set. While somewhat unexpected, this is the correct behaviour for strata --- there is a way to get the results you want though.

The solution is to add a ?when variable to your query, and use the consider block to force strata to consider a variable as relevant:

<table ?who ?beans@sum >
?b is a: beans
?b who: ?who
?b when: ?when
?b beans: ?beans
group {
  ?who
}
consider {
  ?when
}
</table>

The consider block informs strata that a variable is relevant for the uniqueness of the results, even though it is not part of the displayed fields.

Let me know if this helps!

P.S.: In your example you have three entries with names. I'm assuming they are on different pages. If not, note that if you put multiple entries in a single page Strata will merge them unless you give them unique names. A quick example of this can be seen in issue #41.

from dokuwiki-strata.

pop-ch avatar pop-ch commented on June 12, 2024

Thank you, this explains the funny results perfectly well. I did not understand before the use for the consider block. Now I do.
The example is, of course, contrived and I put all the data on one page in order to simplify the documentation of the issue. The result of the query appears to be the same when I add names to the entries.
Instead of the field when, I can also use the entry title to disambiguate the rows.
All's well, the issue is solved, strata is an astonishingly flexible beast. Thank you.

from dokuwiki-strata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.