-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Ratio between Aggregated Columns #2994
Unanswered
momed-sakka
asked this question in
Q&A
-
Hi,
is it possible to create a column as a ratio between two columns (post aggregation) in pivot mode ?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
You may use a pivoted View as an input to Client::table, which can then calculate a ratio with an expression column.
const table = await worker.table(superstore_arrow); const view = await table.view({ group_by: ["State"] }); const table2 = await worker.table(view, { index: "State (Group by 1)" }); await viewer.load(table2); await viewer.restore({ "filter": [["State (Group by 1)", "is not null", null]], "expressions": { "\"Sales\" / \"Profit\"": "\"Sales\" / \"Profit\"" }, "group_by": [ "State (Group by 1)" ], "columns": [ "\"Sales\" / \"Profit\"" ], })
This doesn't work well with real-time data yet, you must be careful to hook up both update and remove listeners and deal with group headers with filters, and set the index correctly. It also must be done during table construction, which makes it complicated to control the group_by from the UI (you can use a workspace or separate viewer, but this workflow is complex).
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment