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

Is there a way to perform conditional accumulation in the table? #1166

Open
awayme opened this issue Dec 16, 2024 · 6 comments
Open

Is there a way to perform conditional accumulation in the table? #1166

awayme opened this issue Dec 16, 2024 · 6 comments
Labels
question Further information is requested

Comments

@awayme
Copy link

awayme commented Dec 16, 2024

For example, I have two columns:
a b
0 1
1 2
0 4
1 6
1 8

I want column C to show the cumulative sum of column B up to the current row, excluding rows where column A equals 1.

@caoxing9
Copy link
Contributor

formula field support logical case. It work for this.
image

@caoxing9 caoxing9 added the question Further information is requested label Dec 18, 2024
@awayme
Copy link
Author

awayme commented Dec 20, 2024

image

Thank you for the reply, but sorry, I still don't understand.
I've made another practical table to illustrate the calculation I'm hoping for, with the last column being what I need. I want to cumulatively add the scores in the second column row by row, but if the third column is 'in progress', I don't add, and I keep the previous number.

Your suggestion was to use logical judgments to handle this, which I understand, but my understanding is that you were referring to an addition operation within one row, without providing a way to perform vertical operations across rows.

What I had in mind was there should be a filter and a variable representing all values in a certain column up to the current row, which would enable this conditional cumulative addition, like sum(filter(ColumnValuesUntilCurPosition(), condition)).

Perhaps I misunderstood your meaning?

@kpodp0ra
Copy link
Contributor

sum(filter(ColumnValuesUntilCurPosition(), condition))

I don't think it's even possible to implement order-depended variables, as order in Teable is tied to view.
It would be terribly confusing due to view nature, as if different data appeared in view A and different data in view B.

I can work around this with "Previous" field:

Number roll-up field

Previous field

@caoxing9
Copy link
Contributor

caoxing9 commented Dec 20, 2024

image

Thank you for the reply, but sorry, I still don't understand. I've made another practical table to illustrate the calculation I'm hoping for, with the last column being what I need. I want to cumulatively add the scores in the second column row by row, but if the third column is 'in progress', I don't add, and I keep the previous number.

Your suggestion was to use logical judgments to handle this, which I understand, but my understanding is that you were referring to an addition operation within one row, without providing a way to perform vertical operations across rows.

What I had in mind was there should be a filter and a variable representing all values in a certain column up to the current row, which would enable this conditional cumulative addition, like sum(filter(ColumnValuesUntilCurPosition(), condition)).

Perhaps I misunderstood your meaning?

I got you. Frankly, formula does not support such case.
Perhaps the comming feature which support script action in automation, you can write a custom logic to calculate and write the specific cell.

@awayme
Copy link
Author

awayme commented Dec 21, 2024

image
Thank you for the reply, but sorry, I still don't understand. I've made another practical table to illustrate the calculation I'm hoping for, with the last column being what I need. I want to cumulatively add the scores in the second column row by row, but if the third column is 'in progress', I don't add, and I keep the previous number.
Your suggestion was to use logical judgments to handle this, which I understand, but my understanding is that you were referring to an addition operation within one row, without providing a way to perform vertical operations across rows.
What I had in mind was there should be a filter and a variable representing all values in a certain column up to the current row, which would enable this conditional cumulative addition, like sum(filter(ColumnValuesUntilCurPosition(), condition)).
Perhaps I misunderstood your meaning?

I got you. Frankly, formula does not support such case. Perhaps the comming feature which support script action in automation, you can write a custom logic to calculate and write the specific cell.

Thanks! I'm really looking forward to seeing this feature implemented and released soon.

@awayme
Copy link
Author

awayme commented Dec 21, 2024

tied to view

Thank you for your workaround; it's a viable solution for now. I had tried using Rollup before but failed because I was unaware that the "link to another table" field could link back to itself.

As you mentioned, indeed, the order is tied to the view, which poses a problem but also serves as a feature. This way, I can achieve different accumulative sums with different orders in various views, which is quite common in many business data analysis scenarios. I've used this feature in other similar products like Lurke.

Thank you once again for your workaround method.

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

No branches or pull requests

3 participants