How to select one to many related table's first instance's field as display template? - directus

I have 2 tables with these fields:
items (date, ...)
items_translations (title, ...)
I want to select title field of first items_translations as display template of items table. But I can only select items_translations table as a whole which shows [1] because of one to many relationship.
Is there any way to select only the first items_translations's title field?
I use Directus 9.
As you can see, the User Created can be clicked, and then only one field can be selected. I think my question is a little bit weird but I think it is very often requested because of the translation table.

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.

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.

Show a column value but submit another value in Microsoft Access

I am trying to make a simple form that 'registers' users into a meeting. I'm trying to get the form to submit the meeting 'id' into the database but I wish to display a different value for the user (so that they do not stumble through meeting id's). I've added two columns to the query (meeting id and meeting information) but I am unsure how I would get the form to submit the meeting ID but display the meeting information for the current user.
EDIT: I've tried your method Chris but it doesn't seem to work.
Edits made:
http://i.stack.imgur.com/6IUuD.png
http://i.stack.imgur.com/3PTTZ.png
You need a rowsource query with TWO values because you have two columns. For example:
SELECT meeting_id, meeting_name
FROM meetings
In this case the 'bound column' property would be '1' because in the example you first select the meeting_id.
In the 'column width' property you then type "0cm;4cm". 0cm means that the first column (the IDs) will not be shown.
go to design view of the form and change the bound column to the number that represents the column you desire to have displayed. eg.
You can add the query at the Row Source as in the image a query builder will appear and you just create the query and save it.

I need to generate two letters to a person (one for each address). How can I accomplish this?

I would like to create two letters for a single person. One letter will be sent to a person's old address and another will be sent to a person's new address. Would this be two different reports with a slight variation in the SQL or is there a way to simply create both letters with a single report?
In a normallized database, you would show the old address and new address in two separate records, perhaps in a related table linked by person ID or something similar. You should look up and read about normalization. Certainly you should aim for at least 3rd normal form.
For your current problem, you could create a unionized view
select NewAddress As Address from TableName
union
select OldAddress as Address from TableName
Then report on the values in the view.
You might want to have some more fields as well, such as the person's name.
The fields you select in the first select statement must be the same number and type as those in the second select statement.
Also you can still add a where clause and an order by clause.
Check on the union operator online.
Hope this helps
Harv
There are a couple of approaches you could use:
union the old and new addresses in the query, then report on the query with a single detail section for each dataset row.
alternatively, report off the Table and include two detail rows, one each for the old and new address, and conditionally suppress each section depending on whether the relevant address is NULL.

How can I bind a multi-row update or insert statement to a form?

I have a table Prices:
ID -- primary key, autonumber long integer
PriceDate -- Date
Price - Currency
Quantity - Number, DECIMAL subtype
UnitPrice - Number, DECIMAL subtype (an update statement is run to keep this in synch with price and quantity, but it's just a convenience for indexing... probably it'll be replaced with an expression in my queries)
ItemNote - Text
NewStores_ID - long integer key, lookup to another table of stores
NewItems_ID - long integer key, lookup to another table of items
To enter prices for a given store on a given day, I would like to be able to select the store and date ONCE on a form, then enter the items individually in a datasheet. For reasons unexplained, this proves difficult.
I can create a subform binding everything but the store and price to a temp table TempPrices with the same structure as the original. Then I run the SQL statement
INSERT INTO Prices
(PriceDate,Price,Quantity,UnitPrice,Brand,ItemNote,NewStores_ID,NewItems_ID)
SELECT
PriceDate,Price,Quantity,Price/Quantity AS
UnitPrice,Brand,ItemNote,NewStores_ID,NewItems_ID)
FROM Temp_Prices;
This will feed all the new rows into the main table. But, when I want to set the store and date only once, I run into problems. I've tried using named parameters for date an store in the insert statement... which can cause a pop-up prompt, but I cannot bind it to a form control. I've tried binding an update statement for those fields in the temp table to a form... but it doesn't even show an option to bind a multi-row update.
How can I get this to work with a minimum of clumsy hackery? It seems like there ought to be a simple solution, and if I were using something like PHP or JDBC I'd just run an extra query.
Edit: changed storage type for Quantity and UnitPrice to Number, Decimal subtype in place of double float. Just so people won't cry about using a float in any proximity to currency. It doesn't pose a problem in my use, but there are enough people who have a knee-jerk reaction to that.
Edit 2: Form/Subform
I'm trying to structure this as a master form with a either fields for entering store name and date, or a subform for the same, then a subform mapping to the temporary table for entering pricing data. There is an action button to run the insert/update queries to dump the temp table into my main prices table and clear out the temp table. However, the problem is that I can't figure out how to get the date/store fields in the master (or subform) to bind to an insert/update value applied to all the new rows at once.
Edit 3: SQL Statements (for clarity)
INSERT INTO
PRICES(NewStores_ID,PriceDate,NewItems_ID,Brand,Price,Quantity,
UnitPrice,ItemNote)
SELECT
#MyStore_ID,#MyPriceDate,NewItems_ID,Brand,Price,Quantity,
Price/Quantity,ItemNote
FROM TempPrices;
UPDATE TempPrices SET PriceDate=#MyPriceDate,NewStores_ID=#MyStoreID;
For these queries, I cannot bind parameters for #MyStore_ID or #MyPriceDate to fields in any form. The queries don't show up as options when trying to link them to a form. I can run them and get popup boxes to input parameters, but that's not what I want.
This is the target I'm aiming at:
"I would like to be able to select the store and date ONCE on a form, then enter the items individually in a datasheet."
However, if you have a reason why you need to do it with a temp table and DML statements, then this suggestion will not be useful.
I created a Prices table with only 4 fields, then a query on that table which I used as the Record Source for a form, "fsubPrices":
SELECT p.ID, p.NewStores_ID, p.PriceDate, p.Price
FROM Prices AS p
ORDER BY p.NewStores_ID, p.PriceDate;
The form has text boxes (txtNewStores_ID, txtPriceDate, and txtPrice) bound to the similarly-named query fields. I set Enabled=Yes for txtPrice, and Enabled=No for the other two.
Then I created an unbound form "frmPrices", and in the form header added a combo box "cboStores" and a text box "txtPriceDate". The combo has Bound Column = 1 with this query for its Row Source:
SELECT l.Store_ID, l.Store_name FROM tblkupStores AS l ORDER BY l.Store_name;
Then I added fsubPrices as a subform control to the detail section of frmPrices. The tricky part is setting the Link Master/Child Fields. There is a "wizardy dialog thing", but it will only allow you to select from the available fields, and I needed to link controls on the main form with fields on the subform. To do that, I had to type what I wanted directly into the subform control's property sheet:
Link Child Fields......NewStores_ID;PriceDate
Link Master Fields.....cboStores;txtPriceDate
The result is ... choose a store and date combination in the main form ... any matching records are displayed in the subform. You can navigate to the "new record" in the subform to add records for that store/date combination. But the txtNewStores_ID and txtPriceDate controls don't show the updated values until the new record is saved.
I hope this is close to what you want. It's actually fairly quick and easy to create; not so easy to describe.
You can't really do that. You are always going to have one row being worked with at a time.
What you can do is simulate it by changing the form's Default View from "Single Form" to "Continuous Form" or perhaps "Data sheet" and making is a child(sub) form of a master form.
Then you can put the store and date on the Master form, and linking to the child form using the NewStores_ID and PriceDate fields.