Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple calculated fields in fields.ini #115

Open
viharm opened this issue Dec 27, 2019 · 6 comments
Open

Multiple calculated fields in fields.ini #115

viharm opened this issue Dec 27, 2019 · 6 comments

Comments

@viharm
Copy link

viharm commented Dec 27, 2019

Hi @shannah , I've always been a fan of Xataface and very much appreciate the work you have been doing for years. I very much enjoyed your guidance whilst creating the LDAP auth plugin.

I am creating a personal inventory application which has tables for items (tbl__Item) and categories (tbl__Category). I have established a many-to-many relationship between these two tables using relationships.ini.

I would like to count the number and the total cost of items in a category when I list the categories.

I have followed the guide at http://xataface.com/documentation/how-to/how-to-add-calculated-fields-to-your-list-and-details-view to add the count using a SQL statement in the beginning of fields.ini for the categories table (tbl__Category).

However when I add the second SQL statement for cost, the list view shows only the cost. Is there a way to have multiple calculated fields in a list and browse views?

@LHammonds
Copy link

If the result can only show the ID and another field, use the concat() function in the database to create the desired display as a single field using SQL. I have used concat() to modify a dropdown list that just showed a city location name to also show the State+City as if it were a single selection.

@airdrummer
Copy link
Contributor

i'd also like to add a total to a list of related records, but the docs page referenced by OP says:
What did this NOT do? So far this only helps us for the list tab and the View tab. This extra column will not show up in related records lists. Possibly in future versions, this support will be added.
as this page is "as of 0.6.3" is there a way now?

1 similar comment
@airdrummer
Copy link
Contributor

i'd also like to add a total to a list of related records, but the docs page referenced by OP says:
What did this NOT do? So far this only helps us for the list tab and the View tab. This extra column will not show up in related records lists. Possibly in future versions, this support will be added.
as this page is "as of 0.6.3" is there a way now?

@viharm
Copy link
Author

viharm commented Oct 5, 2020

@LHammonds , thanks for your input, however wouldn't the concatenation logic apply to string fields? I was trying to include two calculated fields to show total count and total cost. Would your suggestion still be applicable?

@LHammonds
Copy link

@viharm , you should be able to concatenate it. The concat() function will convert any column input into a string before the operation. And of course, any output from the function will be of string type. You could make the result field end up looking something like "Count=##, Total=$##.##"

@viharm
Copy link
Author

viharm commented Nov 19, 2020

@LHammonds , thanks, I’ll try this out, but will need a separate test install for this, so will need some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants