Hi Everyone,
I a new to using redash. I am currently working on battery data which is Postgres. I have the following type of data.
impedance | cell_id | Cycle_Number
1.1 | 1 | 500
1.8 | 1 | 520
2.0 | 1 | 550
1.0 | 2 | 100
1.4 | 2 | 220
2.5 | 2 | 550

What I want to do is I want to create a plot of Impedance VS Cycle_Number for each cell. I want to use cell_id as query parameters or filters. What I want is when I select multi-query parameters The cell_id 2 should be added along with cell_id 1.
I want to implement something like this.


Here, when there is only one cell_id you can see 3 legends that are associated with that cell.
Now, If I add another cell I will get 6 legends i.e all the series associated with that cell.
. I want to implement similar thing with my impedance data.
Can somebody help me out with this.

Thanks,
Omkar

Have you tried using a SUM aggregation and a serialized dropdown list parameter?

I ran this SQL to simulate your data:

SELECT 
cell_id,
impedance,
sum(cycles_number) as "cycles"

FROM (
VALUES
(1.1 , 1 , 500),
(1.8 , 1 , 520),
(2.0 , 1 , 550),
(1.0 , 2 , 100),
(1.4 , 2 , 220),
(2.5 , 2 , 550
)
)base(impedance, cell_id, cycles_number)  

WHERE cell_id IN ({{ cell_id }})
GROUP BY impedance, cell_id

And it let me sum together the cycle number for each impedance and ID. Is this what you need?

Thanks a lot. It worked. That was exactly what I required

1 Like

@k4s1m What modifications do I have to make if I want to add another parameter of the cell.
There is another column in the data.
Eg,charge | impedance | cell_id | Cycle_Number
1 |1.1 | 1 | 500
1.2 |1.8 | 1 | 520
1.4 | 2.0 | 1 | 550
1.6 | 1.0 | 2 | 100
1.3 |1.4 | 2 | 220
1.2 |2.5 | 2 | 550
I want to have charge and impedance for each cell in the plot with legend as Charge_cell_1,Impedance_cell_1,Charge_cell_2,Impedance_cell_2. I want to do the exact same thing as they have done in the above images. Can you please tell me what modifications do I have to make to the query.

Thanks,
Omkar

Note: you provided insufficient data to make a line chart (there must be at least two samples for each charge-cell combination).

For this, just concatenate the charge and cell_id fields.

SELECT 
charge || '_' || cell_id "id_and_charge",
impedance,
sum(cycles_number) as "cycles"

FROM (
VALUES
(1,1.1,1,500),
(1.2,1.8,1,520),
(1.4,2.0,1,550),
(1.6,1.0,2,100),
(1.3,1.4,2,220),
(1.2,2.5,2,550)
)base(charge,impedance, cell_id, cycles_number)  

WHERE cell_id IN ({{ cell_id }})
GROUP BY impedance, charge || '_' || cell_id

@k4s1m I am sorry I wasn’t clear, I don’t want a actual values of Charge and impedance in the column as legends. What I want is legends to be “Charge_Cell_1”, “Impedance_cell_1” ,“Charge_cell_2” ,“Impedance_cell_2” And when I toggle to cell_1 in the query parameter,it should display plot of Charge and Impedance of cell_1 VS Cycle_Number with legends as “Charge_Cell_1”, “Impedance_cell_1” and with Cell_2 as “Charge_Cell_2”, “Impedance_cell_2”.
Also, If I select both I should be to see the plot with these 4 legends.
Is it possible to do it? Also, what modifications are needed.

Thanks,
Omkar Bhambure

Sure, you’ll just need to adjust your query accordingly. So far you had cycles along the X axis and impedance on the Y axis. If you also need to show charge on the Y-axis you’ll need to take this into account.

You have all the pieces needed to construct that query now. Definitely check out the documentation that describes how chart visualizations work to learn more.

That’s as much help as I can provide.

1 Like