I work for a pharmacy. One way of classifying drugs is an identifier called GPI. The digits in the GPI have meaning, and a parent-child relationship.
In my database, I have a table of groups, a table of classes (includes groups), and a table of subclasses (includes groups and classes). The number values for classes are repeated over the groups. For example, group 01 might have class 01, 02, 03, and 04. Group 02 might also have 01, 02, 03, and 04. The classes are different in each group, they use have the same identifier.
In JasperReports Server 4.7 I have a multi-select query input control that displays the GPI groups. I also have a multi-select query cascading input control that takes the gpi_group value to display a list of classes. Here's the query that populates the cascading input control:
SELECT DRUG_GROUP, DRUG_CLASS, CLASS_NAME
FROM Schema.DRUG_CLASSES
WHERE $X{IN, DRUG_GROUP, gpi_group}
ORDER BY DRUG_GROUP, DRUG_CLASS
Visible columns: DRUG_GROUP, DRUG_CLASS, CLASS_NAME
Value column: DRUG_CLASS
And it works great when I select one drug group. Here's group 01:
And here's group 02:
But when I select them together:
The input control doesn't seem to like the duplicate values of the GPI Class that occur when multiple GPI Groups are selected. If I change the value column to GPI Class Name (where there are no duplicates) the display is as desired:
However, I don't want my value column to be the GPI Class Name, I want it to be the GPI Class. I'd like to constrain my GPI Subclass input control on the values that come from the GPI Group and GPI Class input controls, and I'd like to feed GPI Group, GPI Class, and GPI Subclass into my query.
Any thoughts on how I can get that cascading input control to display the 'duplicate' GPI Class values?
Here's what I've decided to do --
The input controls want a unique value in the value column. I don't think there's any way around this so I'm just going to roll with it. I'll handle the concatenated strings in my query.
Query for GPI Class cascading input control:
SELECT
DRUG_GROUP,
DRUG_CLASS,
CLASS_NAME,
DRUG_GROUP||DRUG_CLASS AS GROUP_CLASS
FROM Schema.DRUG_CLASSES
WHERE $X{IN, DRUG_GROUP, gpi_group}
Value column: GROUP_CLASS (a concatentation of GPI Group and GPI Class)
Query for GPI Subclass cascading input control:
SELECT
DRUG_GROUP,
DRUG_CLASS,
GROUP_CLASS,
DRUG_SUBCLASS,
GROUP_CLASS_SUBCLASS,
DRUG_SUBCLASSNAME
FROM (
SELECT
DRUG_GROUP,
DRUG_CLASS,
DRUG_GROUP||DRUG_CLASS AS GROUP_CLASS,
DRUG_SUBCLASS,
DRUG_GROUP||DRUG_CLASS||DRUG_SUBCLASS AS GROUP_CLASS_SUBCLASS,
DRUG_SUBCLASSNAME
FROM Schema.DRUG_SUBCLASSES
)
WHERE $X{IN, GROUP_CLASS, gpi_class_cas}
Value column: GROUP_CLASS_SUBCLASS (a concatenation of GPI Group, GPI Class, and GPI Subclass)
Related
I am attempting to union join 2 tables in my Microsoft NAV data source within Tableau. However, I have two field named "No." that do not contain the same data.
When I apply a union join, Tableau automatically merges these fields and I cannot un-merge them.
Is there a way to un-merge these fields?
Or is there a way of doing a manual union join?
I have tried renaming the field before dragging the second table into the worksheet however I can see that the "Remote Field Name" still remains the same.
Thanks
One approach is to let Tableau merge the fields and then use the generated fields to distinguish between them.
When you perform a Union in Tableau, it adds a few fields to your data source so you can tell which data rows came from which tables. The most useful in your case is called [Table Name]. So when you build your visualizations, you can use the [Table Name] field to know how to interpret the [No.] field.
If that is awkward, you can create 2 calculated fields to represent only those [No.] values that have the same role. For example, define [No. Type 1] as if [Table Name] = “Table 1” then [No.] end. And define, [No. Type 2] similarly. Then you can hide the original [No.] field.
These new fields will only have values for the appropriate data rows, and will be null otherwise. Aggregate functions like SUM(), AVG() etc ignore nulls, so you can use those fields as measures easily.
If you want to use a calculation in a JOIN clause, say after making a UNION, then first specify the tables (or unions of tables) to join, then when you click on the Venn diagram to specify the join keys, and then select either the left or right list of fields --> look at the bottom of the list in small print to either create or edit your Join Calculation.
Is it possible to dynamically change the where clause as a query executes based on the value of one of the columns? That is, lets say (and this is a completely made up example) I have a table of students, classes attended, and if they were tardy. I want to see for each student a list of all classes they have attended since the last time they were tardy. So the query would look something like this:
SELECT student, class, classdate
FROM attendance
WHERE classdate>(<<SOME QUERY that selects the most recent tardy for each student>>)
ORDER BY student,classdate;
or, to put it into more programing terminology, to perhaps make it clearer:
for studentName in (SELECT distinct(student) FROM attendance):
SELECT student, class, classdate
FROM attendance
WHERE classdate>(SELECT classdate
FROM attendance
WHERE tardy=true AND student=studentName
ORDER BY classdate DESC
LIMIT 1)
ORDER BY classdate;
Is there any way to do this with a single query, or do I need to do a separate query for each student (essentially as per the loop above)? The actual use case is more complicated to explain (it has to do with certifying records, and which ones need to be looked at) but conceptually it is the same.
Just use multiple aliases (e.g. a1 and a2) for the attendance table, so you can refer to the "outer" table alias in the subquery:
SELECT student, class, classdate
FROM attendance a1
WHERE classdate>(SELECT classdate
FROM attendance a2
WHERE tardy=true AND a2.student=a1.student
ORDER BY classdate DESC
LIMIT 1)
ORDER BY classdate;
I have a table with Orders and a subtable with itemId's (one to many relationship)
In the form i have a Combobox to select a specific Order and another Combobox to select a specific itemId.
For this i have made a Query to view all aviable itemId's in the second Combobox.
I dont know how to view the selected itemId-data in the form.
You can use the Where argument of the Openform action to specify the item.
OpenForm FormName, , , "ItemID=" & ComboName
-- http://msdn.microsoft.com/en-us/library/aa141520(v=office.10).aspx
This assumes that the bound column of the combo is a numeric ID that relates to an ID in the form to be opened.
I have a crystal 2008 report that allows users to group to two levels.
I have two parameters, using which users can select which attribute they want to group on.
The two params are of type string and the list of values is static. Both levels have the same options to group on.
Is there someway to filter the list based on what they selected for param 1. So that they cannot group on the same thing twice.
I don't think it's possible. You can cascade dynamic parameters link Country, State but not how you want to.
How many options do they have to choose from? Do they normally choose anything other than a few different combinations from the maximum?
I think you're options are to either leave it as is (allowing them to pick the same thing for both groups). Or create a single parameters which looks like- Group by:
Date, Country
Type, Country
Date, Type
etc
Short answer: not possible.
Options:
create a custom UI that does what you want to do
if the list of grouping fields aren't too long, you could combine the two parameters into a single one, then list the options that you want to support. For example, if you have 3 grouping fields (A,B,C), your single, combined parameter would be A->B, B->A, B->C, C->B, A->C, C->A.
I would like to have the distinct values of a repeating field listed in another field (in browse mode). The case is as follows:
I have a field that contains country names. The country names in this field may repeat themselves, thus when using the "List" function I get something like "France, France, France, Germany, Germany, Hungary".
How can I create a field that lists all the values from my country field, but has it grouped as "France, Germany, Hungary"?
In the case I could directly use a SQL query to interfere with the FileMaker databse I would use the GROUP BY statement.
To make a summary of all the values across every record, do as follows:
Make a new value list labeled 'Countries' (File Menu > Manage > Value Lists)
Make the value list 'Use Values From Field' and specify your repeating field
Create a new Calculation field, 'Listed Countries'
Set the calculation to type 'Text' and with the following code:
ValueListItems ( Get(FileName) ; "Countries" )
If you'd like to find the value for only the current record:
Make a new Table Occurrence, 'NewTO' of the same base table and link the two records by a unique index.
Change the 'Countries' value list so that it obtains values from 'NewTO' and your repeating field.
Select 'Only include related values starting from' and select your original Table Occurrence
If you'd like the list to update as the repeating field value changes, make certain that you Do Not Store Calculation Results for the field.