Can searchbuilder compare 2 columns.

Can searchbuilder compare 2 columns.

gsandersgsanders Posts: 6Questions: 2Answers: 0

Is it possible for searchbuilder to filter out rows where one column is less than the other (or vice versa). One specific case I have involves a duedate column and a completed date column , the user would like to see all "late entries" , i.e. where the Completed date is after the duedate. I haven't been able to figure out a way to do this using the conditions available.

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @gsanders ,

    Currently I'm afraid it is not possible to create a condition that crosses columns. That being said, I can see the use for this and I like the idea. I've filed it internally and we will look into it in future, although I am not sure when yet!

    In the mean time you could create a custom search filter to do this. Take a look at the documentation for writing plugins here.

    Thanks,
    Sandy

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    One way to do it would be to create an additional column in the table, then use columns.render to subtract the two dates (using /Moment.js, as it's excellent for all time/date based operations) and return true/false based on that sum. You could then use SearchBuilder against that additional column.

    Colin

  • gsandersgsanders Posts: 6Questions: 2Answers: 0

    Sandy,
    Thanks for the answer. I'll have a look at the plugin documentation.
    Colin,
    Using column renders would not work for me since I use a generic initialisation method for the table (the dataset returned will vary greatly). Some of the tables generated will have multiple date columns while others will have none. The technique you described would definitely work if I knew ahead of time what columns are in the dataset.
    thanks for the help!

This discussion has been closed.