Create list of display fields and checkbox fields from a table column in Oracle Apex - sql

I am trying to create a list of display fields and checkbox fields from a table column in Oracle Apex. For example, let's say I have a Table A. These are the values stored in A.
ID Health Conditions
-- -----------------
1 Heart Disease
2 High Blood Pressure
3 Diabetes
So now I want to display these 3 display fields associated with 3 checkboxes so the users can choose whether they have the above health conditions problems. If Table A has n values, then I can dynamically display n fields with n checkboxes. How can I do this?

The way I understood the problem, you should pre-populate table (which will contain info about those health conditions) and display the whole list as Interactive Grid (or Tabular Form, depending on Apex version you use).
It means that you'd store non-checked values as well (though, you could delete such rows on submit).
Alternatively, if you create an "empty" Interactive Grid page and let users add rows, and for each row select health condition they have, you'd store only selected values.
Yet another option is to create a page with shuttle item (or select list that allows multiple selections) so that user would select only desired values and store them. Drowback of such an approach is that all values are stored into the same column (read: it is not normalized) separated by colons. That's OK for selecting values, but causes problems later when you have to do something with it as you have to first split values into rows and then do that something.

Related

How can I have multiple tables on one SSRS page that represents one value in SQL?

I have developed a one page report that has 4 tables on it. I am happy with this result:
This is shown for one district. (district = '002') The dataset only has the one district selected. I want to select multiple districts (a SQL field) in the dataset and have multiple pages representing one district per page. So, to state in a different way, there are about 10 districts so I want to have 10 pages just like this one with one district per page. It seems like there should be some sort of grouping option so I can show this page for each district. I'm new to SSRS so I'm probably missing something obvious. Thanks!
This set of tables can be repeated for each selected district with one set on each page. To achieve this, you can take advantage of nested tables.
Create a new table with one row and one column.
Set it to be grouped on district.
Set the group to page break after each instance. And optionally set the page name to be the district. This way, if you export to Excel, the sheets will be properly named.
Insert all the other tables into a Rectangle. This is a way of keeping the formatting of the other tables in tact and handle them all together.
Drag the rectangle into the new one-cell table.
Now the small table will repeat the entire contents of the rectangle for each district and you get copies of the entire report on separate pages.

One column per report page

I have a 4x4 table in SQL with 20 rows. I want to split this data into four pages. Page 1 has the first 10 rows of the first column, Page 2 has the first 10 rows of the second column, etc.
After every four pages, this patern repeats showing the next 10 rows from the first column, etc. How can I arrange this?
I could arrange the data of the 4x4 table into another temporary table with just one column in its schema. Then I could read a single column of this table into my report. But can I instead do this directly without an intermediary table?
The intermediary table sounds like the best solution to me. I'd just write a custom SQL command in Crystal's Database Expert to arrange the data as you see fit.
You could in theory pull this off with repeating subreports in some manner of repeating header, but it would be much less work to have SQL properly format the incoming data for you.

Qlikview: how to create summary table to filter multiple associated tables

I have 4-5 tables of single and many rows per ID. I want to generate a summary table listing each ID along with various counts and max/mins, but I want to be able to filter on calculations. Example: "ID" is the identifier and there are two tables, TestA and TestB.
One desired selection criteria: Show only those IDs where at least one TestA score >5 and there is at least one TestB score.
In a straight table, this is simple to do with expressions, but the resulting table cannot be selected on the calculated true/false value.
I think I need to create a new table in the load script containing the ID, and then various conditions labeled as I wish. Then, these fields could be dimensions. This seems similar in concept to a master calendar. Am I on the right track?
If it helps to understand my example, this a medical application; the tables are lab results and other interventions that each require complex queries pulling data from various sources that are very "hard-coded" to produce a small data set from millions of rows of highly normalized source data. The desired dimensions would be combinations of the labs so as to allow identification of patients who meet certain criteria--then, once filtered, there would be many more graphs and charts to identify what tests and procedures were followed for that group of patients.
My current data model just loads many tables which then associate on ID. I had attempted to load all data into one big table using concatenates and calculations, but this did not seem to accomplish what I needed and was difficult to manage.
IIUC, I think what you want to do can be accomplished with a combination of sliders/input boxes, variables and calculated dimensions in your table. The process is definitely burdensome, but it should allow you filter the way you want.
Add a field to your table load statement in your script like rnum as RowNo().
Create a variable for your filter(s). Ex. vFilterTestAScore.
Add a slider or input box to your dashboard and point it to that variable.
a. For slider, the option is in the General tab -> Data header -> select the Variable radio button.
b. For input box, add the correct var from the list to the list of Displayed Variables.
Set sliders/input boxes to the criteria you want: vFilterTestAScore = 5 and vFilterTestBScore = 1
Create a straight table with ID as the dimension and expressions for TestAScore and TestBScore. The expression formulas would be sum(TestAScore) and sum(TestBScore) respectively (this won't make sense until the next step).
Now add a calculated dimension to you table. The idea here is that rather than just having the ID dimension, you will create a calculated dimension that only displays the ID of the records that meet the criteria you select in the slider or enter in the input box. The formula should be something like:
if(aggr(sum(TestA), rnum) >= vFilterTestAScore, ID, null()) or for multiple filters: if((aggr(sum(TestA), rnum) >= vFilterTestAScore) and (aggr(sum(TestB), rnum) >= vFilterTestBScore), ID, null()).
On your new calculated dimension, check the 'Suppress When Value is Null' box so only results that meet your criteria are displayed in your table.
To summarize, you are using the variables to store your selection criteria which you are entering via input box or slider. Then you are conditionally displaying only the ID's in your table that match those criteria via a calculated dimension and 'Suppress When Null' option.
I can send you a .qvw if you aren't using the free personal edition and are able to open other qvw's.

how to display parent record and children from multiple tables

I have three tables, 1 parent with 2 child table 1-to-many relationships.
table 1: People
table 2: Phone numbers (any number of records)
table 3: email adresses (any number of records)
I would like a report looking like this:
Person1:
First_Name-------Last_Name
phone1:------12345----Home
phone2:------54321----work
mail1:-------first#mail.com----work
mail2:-------first#mail.com----work
mail3:-------first#mail.com----work
Person2:
-------First_Name-------Last_Name
phone1:------12345----Home
phone2:------54321----work
mail1:-------first#mail.com----work
mail2:-------first#mail.com----work
mail3:-------first#mail.com----work
I would very much like to do this using reporting services.
Edit: I know how to link all tables with left joins, I don't have a concept as how to get this done.
OK, here's a sort of summary of how you need to approach it. I can't give you a step-by-step because it would be impossibly long, but this should get you started. (Also note that I'm doing this from memory):
You will need three datasets, one each for people, phone numbers, and email addresses. I am going to assume that the phone numbers and email addresses have some kind of ID field in common, some way to tie people to phones and to email addresses. You will need that field in your datasets.
You don't need to do any joins in your SQL: the linking between the three datasets will be done within the report.
Put a Matrix on your report. Have it draw from the People dataset. Put the first and last name in the detail row of the Matrix.
Add a new detail row to your Matrix, under your first and last name.
Merge the cells in your new detail row so that you have one very wide cell.
Embed (drag and drop) a new Matrix in the single wide cell in your new detail row.
Link your matrix to the Phones dataset. Set up a record filter in the matrix to limit the records to those that match the ID field in the parent matrix.
Set up the Phones as you want in the embedded child Matrix.
Repeat steps 3-7 with the Email Addresses dataset.
You don't actually need to do any grouping (unless you want to include subtotals of some kind), because you're not actually grouping anything: you're just displaying a list with embedded sub-lists.

Populate combo box with distinct values from one table based on values existing in another?

I am trying to populate a combo box with distinct values pulled from a clients table, but only if those clients exist in the mfgOrders table. I have set the Row Source to the following query:
SELECT DISTINCT Client.ClientName FROM Client
INNER JOIN mfgOrders ON Client.id=mfgOrders.client;
When I switch to Datasheet view, I can see all the distinct clients that are also in the mfgOrders table. The problem is that this does not populate in the combo box.
I originally thought that this may be due to the data size, but oddly enough when I select ClientName from Client, it will populate the box successfully but with ALL clients.
Unfortunately, I don't want all clients in the combo box. Just the clients which also appear in the mfgOrders table.
I'm stumped on this one. Is my logic incorrect?
It appears that when linking a drop-down list to a query, the list will be populated based on how many fields are queried.
In this case, despite the first field being used simply to create the union, Access created a combo box with 2 columns, the first of which had a width of 0".
This appears to have been done because the "show" box for the first field in the query was unchecked. The result was a blank list.
To fix the error I simply re-arranged the query.