Filter $labkey.data using a query view

LabKey Support Forum
Filter $labkey.data using a query view rsautera  2013-11-21 14:42
Status: Closed
 
I want to filter some data associated with a report.

I followed the instructions here to create an XML query view:
https://www.labkey.org/wiki/home/Documentation/page.view?name=addCustomQueryView

The organisation of my module is as follow:
├── queries
│   └── hipcdb
│   └── study_pubmed
│   └── study_pubinfo.qview.xml
├── README
├── reports
│   └── schemas
│   └── hipcdb
│   └── study_pubmed
│   └── study_pubinfo.Rmd

My query view is:
<customView xmlns="http://labkey.org/data/xml">
        <filters>
                <filter column="study_accession" operator="eq" value="SDY61"/>
        </filters>
</customView>

No matter what I write in the qview, the report doesn't seem to pick up the changes.

Is a query view the right tool for this?
Is the file tree correct?
Do I have to bounce the server to pick up changes from a queryview? Or a new build is enough?

Renan
 
 
cnathe responded:  2013-11-22 06:56
Renan,
Your module folder tree looks correct for the query view. I tested it locally, and it looks like you might be missing part of the string for the xmlns attribute of the customView element in your XML. If I set the xmlns="http://labkey.org/data/xml/queryCustomView" the study_pubinfo view appears in the views menu of the study_pubmed query for me and was filtered as expected.

Give that a try.
-Cory


<customView xmlns="http://labkey.org/data/xml/queryCustomView">
        <filters>
                <filter column="study_accession" operator="eq" value="SDY61"/>
        </filters>
</customView>
 
rsautera responded:  2013-11-22 10:04
Thanks Cory, it works, I can see the filtered table.
However, I was hoping that the report would be based on this filtered query.

The report only contains

```{r test}
labkey.data
```
And when executed, it displays the entire table, not just one line.

How can I have $labkey.data be based on study_pubinfo?
 
cnathe responded:  2013-11-22 10:40
Sorry, I was focused on how to get the query view in your module working. To have an R report in the module associated with a subset of a table/query, my suggestion would be to add a SQL query to your module and attach the report to that (instead of using a query view).

I have attached a zip archive with the contents of a test module that I created locally that has a study_pubinfo SQL query and R report. When added to the server and the module is enabled, I get the R report to display in the views menu for the study_pubinfo query (note: not the study_pubmed table). Also note that my query and report are attached to the "immport" schema, but the server you are working with likely still refers to this schema as "hipcdb".

Does that fit with your use case?
-Cory
 
rsautera responded:  2013-11-22 10:52
I liked the idea of a view instead of a query but this is close to perfect.
Thank you.