Convert row values to columns using one to many node

Hi,
I am facing problems in plotting a Graph while using one to many node. I was using query in my Database Reader:
(SELECT TIME,
MAX(CASE WHEN (USER = ‘RAM’) THEN USER ELSE NULL END) AS RAM,
MAX(CASE WHEN (USER = ‘SEN’) THEN USER ELSE NULL END) AS SEN,
MAX(CASE WHEN (USER = ‘BEN’) THEN USER ELSE NULL END) AS BEN
FROM
XYZ
WHERE TIME >= CURRENT_TIMESTAMP - INTERVAL ‘24’ HOUR
GROUP BY TIME)

But, now i would like to modify it to more dynamic(in short, i don’t want to write query), seems it s not working proper for me.
Below is my workflow, m i missing something?

Thanks in advance!!

Can you post your workflow with some example data? If your actual data is confidential, maybe some dummy data instead.

When you say you don’t want to write the query, are you saying you want to implement the query logic with KNIME nodes instead?

Also, when you say it isn’t working properly - can you be more specific? The visualization, or the data extract, or…? A step-by-step list of what you want to accomplish would be useful here. The more detail the better.

Hi @ScottF,
i thought of posting dummy data in the form of Excel Sheet. But, with dummy data its working as expected. But with my original data, it is not the case.

If you observe my Query, it is nothing but to convert rows values to columns. Same i’m able to achieve using “one to many” node.(instead of writing a query, i can use one to many node)

But, the problem is i’m not able to plot expected Graph(Visualization of Graph is not as expected, not even readable)

But yeah, here i struggled a bit to take a replica of it. I have given an example below

Users_plot_Using Excel.knwf (16.1 KB)
onetomanytable.xlsx (12.1 KB)

Thanks

Hi @ScottF
Any Suggestions on this?

Hi Team,
Can anyone please Suggest on above problem

Thanks in Advance!!

Let me step back for a minute and ask what you want to visualize. I have a guess; you tell me how close I am.

X-axis: hour of day, independent of date
Y-axis: 0 or 1

So, a line plot to show whether a given user is logged on during a particular hour, with a different colored line for each user. Is that right?

Hi @ScottF,
You are correct. I need hours on the X-axis as i’m plotting only for last 24 hours.
Your third statement is also correct

Please let me know your suggestions of workflow on the same.

Thank you!!

Here’s something to play with. I took your workflow and modified it in a few ways

  1. incorporated a simple component that allows you to enter a DateTime range that you want to filter on
  2. line plot with axes formatting (no string manipulation needed)
  3. scatter plot with colors assigned. This is a bit of a weird way to display the data, but gets around the problem of overlapping when users are logged at the same time, and more discretely shows the pings.

Fiddle with it and see if you can improve it!

Users_plot_Using Excel_SF.knwf (42.0 KB)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.