SQL from an each loop #2636
-
Is it possible to use the outputs of an I want to iterate through a set of items & create a chart for each one. Example:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I tried too and failed to use the same parameter that, inside the each, can be printed with both of: {eachrow.id}
<Value data={eachrow} column=id /> The workaround I could find, which is probably terrible from a performance perspective, was to filter the data using js:
|
Beta Was this translation helpful? Give feedback.
-
The best solution here is very close to your solution, but using a SQL filter in the loop, not JS ```sql query_output
select distinct filter_col
from my_table
```
```sql table_for_chart
select xval, yval, filter_col
from my_table
```
{#each query_output as item}
### Chart of {item.filter_col}
<LineChart
data={query_output.where(`filter_col = ${item.filter_col}`)}
x=xval
y=yval
/>
{/each} |
Beta Was this translation helpful? Give feedback.
The best solution here is very close to your solution, but using a SQL filter in the loop, not JS