I have Grafana and postgres installed and connected. I use grafana to display charts of data I add to postgres. My postgres database has a table with records from multiple sources. The schema looks like this:

```
time   | source | bid | ask
12:01  | bitmex | 10  | 11
12:01  | deribit| 10  | 11
12:02  | bitmex | 9   | 11

```

The exact times per source are different. I’m able to plot different lines for every source:

[![enter image description here](https://i.stack.imgur.com/rLc08.png)](https://i.stack.imgur.com/rLc08.png)

I’m looking to plot the difference (grouped per minute) of two different sources. I think I need to select grouped minutes where “source = x” and the same where “source = y” and subtract those, while keeping the time macros from Grafana in there to keep the whole thing speedy. Can anyone point me in the right direction? I don't think this is at all possible with the "graphical query builder" in grafana.
['https://Stackoverflow.com/questions/55123258', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/843033/']
I wrote some basic example and I used your XML file.. You can examine that..

**XML file**

```
<?xml version="1.0"?>
<ArrayOfInternship xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Internship>
    <Title>Marketing</Title>
    <Start>2019-03-08T00:00:00</Start>
    <End>2019-04-12T00:00:00</End>
    <Supervisor>John Smith</Supervisor>
    <Comments>Web site makeover.</Comments>
  </Internship>  
  <Internship>
    <Title>Marketing 2</Title>
    <Start>2019-03-08T00:00:00</Start>
    <End>2019-04-12T00:00:00</End>
    <Supervisor>John Smith</Supervisor>
    <Comments>Web site makeover.</Comments>
  </Internship> 
</ArrayOfInternship>

```

**this is the model which one is you will use**

```
public class InternshipModel
{
    public string Title { get; set; }
    public string Start { get; set; }
    public string End{ get; set; }
    public string Supervisor{ get; set; }
    public string Comments{ get; set; }
}

```

**this part pars xml file and add to listbox**

```
 // Loading from a file, you can also load from a stream
 var xml = XDocument.Load(@"InternList.xml");

 // Query the data and write out a subset of contacts
 var query = (from c in xml.Root.Descendants("Internship")
              select new InternshipModel
              {
                 Title = c.Element("Title").Value,
                 Start = c.Element("Start").Value,
                 End = c.Element("End").Value,
                 Supervisor = c.Element("Supervisor").Value,
                 Comments = c.Element("Comments").Value
              }).ToList();

 foreach (InternshipModel model in query)
 {
     listBox1.Items.Add("Title: " + model.Title +
                        "Start: " + model.Start +
                        "End: " + model.End +
                        "Supervisor: " + model.Supervisor +
                        "Comments: " + model.Comments);
 }

```
One possible solution

```
XmlDocument xmldocIntern = new XmlDocument();
xmldocIntern.Load(@"InternList.xml");

var oc = new ListBox.ObjectCollection(lstBxListIntern, xmldocIntern.DocumentElement.GetElementsByTagName("Title").Cast<XmlNode>().Select(node => node.InnerText).ToArray());

```