Solved Transform query

Cris VS

Member
Local time
Today, 17:03
Joined
Sep 16, 2021
Messages
75
Hello everyone,

I have created a query in the sample database that I would like to look like the table in the picture. Taking index 135 in Event A as an example, in the query there are two lines for this combination, one with a cross in type "Welcome" and one in type "Wedding". Is there any way to show just one line for each combination of event and index, with all the corresponding types crossed in the same line?

1636721504139.png



Thank you for any help
 

Attachments

Code:
TRANSFORM First("X") AS Expr1
SELECT Table1.Index, Table1.Event
FROM Type INNER JOIN Table1 ON Type.ID = Table1.Type
GROUP BY Table1.Index, Table1.Event
PIVOT Type.Type;
 
Thank you!
 
Hi again, I have a little issue with this code: when it creates the query, it creates an extra column for the indexes where no type has been registered. How can I delete or hide this column? I do not want it to appear in the crosstab query. Thanks
 
Hi. Try adding a WHERE clause to eliminate the missing index.
 
But I want to display the blank indexes (row with no type marked) in the query, it's just that I don't want the column "<>" to show
 
But I want to display the blank indexes (row with no type marked) in the query, it's just that I don't want the column "<>" to show
Hmm, you may have to use the In() clause for the Column Headings.
 
An example would be, taking the picture I posted on the first post, that there was a pair Index-Event with no type specified. In my process, first I define which indexes go with which events and in a second step, decide whether to assign a type and which ones. When building the query, it will create one column for each type and include a "<>" column to mark that "blank" pair. I want this column to disappear, so that if no type is specified that row appears blank, just as it looks in the picture. I tried this but it only allows me to filter the blank rows, not to show them blank
 
What you have presented in the picture looks like the results of a cross tab query. I'm beginning to think that is not the case because the pivot would have already summarized the rows. SO - the problem is that the data is not normalized. You have a repeating group and you are using data (Welcome, Wedding, Graduation, ...) as column headers. Instead of many columns, you need many rows. One for each type. Then, once the data is properly normalized, a simple cross tab query will give you the presentation results you want.
From what I have read I strongly believe it is normalized: there are independent tables for each group of repetition, foreign keys to my main table and all the attributes of each table depend on their primary key. The group type is an independent table which gets "called" through a foreign key.

I am not using the field "Type" as headers, in fact that is my question, if there is a way to plot a query where the headers are the types - only those and always those, in the sense of no "<>" field if one index is blank and no not-showing one of them if there are no indexes, just like it looks here:
1637224885922.png

(This is just a made up table I am using to exemplify what I want to get as output)
I am using the result of the query for export and that is why it is so important for me to get this appearance. Thanks a lot
 

Users who are viewing this thread

Back
Top Bottom