Unify data in a single line

r621

New member
Local time
Today, 20:40
Joined
Dec 18, 2020
Messages
24
Dears,

I need your support about Access, I would like to know, how to unify in a unique line the following data:

WireNo Cabinet Term
WIRE 1 CAB1 1
WIRE 1 CAB1 2
WIRE 1 CAB1 3

I need a unique line with the all information of WireNo in this format:

WireNo Cabinet Term1 Term2 Term3
WIRE 1 CAB1 1 2 3

Could you please let know.
Looking forward for your kind reply.
Regards
 
Hi. Welcome to AWF!

You should be able to do that by using a Crosstab Query.
 
Code:
TRANSFORM Count(yourTable.Cabinet) AS CountOfCabinet
SELECT yourTable.WireNo, yourTable.Cabinet
FROM yourTable
GROUP BY yourTable.WireNo, yourTable.Cabinet
PIVOT "Term" & [Term];
 
Hello, I'va tried what you suggested to me but is not working or I'm not able how to do it...
 
Hello, I'va tried what you suggested to me but is not working or I'm not able how to do it...
Can you post a sample copy of your db with test data?
 
Query1


Tag_NumberJunction BoxMulticable TagTerminal_Number__Name_
18-DFIU-00118-JG-01718-MG-0171
18-DFIU-00118-JG-01718-JG-0172
18-DFIU-00118-JG-01718-MG-0173

This is my Real DB , crossing two tables with a query I've obtained this and I need to have the Terminal Number Name in a unique line like following:

18-DFIU-001 ----18-JG-017 ---- M18-MG-017 ----1 ----2----3

Could you please help me

In attacched DB with a sample table, could you please insert the SQL or VBA code in order to obtain what I mentioned above and then upload the modified db :)

I forgot the number 1---2---3 shall be in separate and new columns

Thanks in advance for your cooperation
 

Attachments

Last edited:
see Query1.
 

Attachments

Thanks Arnelgp , I checked the database but there's only 1 point :

The data in coloumns Terminals 1,Terminals 2,Terminals 3 shall be like 1 2 3 , in the database upload by you are 1 1 1 , I need the following solution:

Table:

Tag_NumberJunction BoxMulticable TagTerminal_Number__Name_
18-DFIU-00118-JG-01718-MG-0171
18-DFIU-00118-JG-01718-JG-0172
18-DFIU-00118-JG-01718-MG-0173

Query1 shall return as below:


IDJunction BoxMulticable TagTerminal 1Terminal 2Terminal 3
1​
18-JG-01718-MG-017
1​
2​
3​

Could you please help me.

Best Regards
 
Last edited:
??? How do you account for different values in Multicable Tag? 18-JG-017 vs 18-MG-017??
 
I'm sorry all multicables are 18-MG-017 is a mistake JG.

Tabella3 Tabella3

IDTag_NumberJunction BoxMulticable TagTerminal_Number__Name_
1​
18-DFIU-00118-JG-01718-MG-0171
2​
18-DFIU-00118-JG-01718-MG-0172
3​
18-DFIU-00118-JG-01718-MG-0173
Query result shall be
IDJunction BoxMulticable TagTerminal 1Terminal 2Terminal 3
118-JG-01718-MG-017123
 
see this.
 

Attachments

Is exactly what I want thank you very much Arnelgp!
But I've a last question :

Suppose that I've a table like this:

Tabella3 Tabella3


IDTag_NumberJunction BoxMulticable TagTerminal_Number__Name_
1​
18-DFIU-00118-JG-01718-MG-0171
2​
18-DFIU-00118-JG-01718-MG-0172
3​
18-DFIU-00118-JG-01718-MG-0173
4​
18-DFIU-00218-JG-01918-MG-0184
5​
18-DFIU-00218-JG-01918-MG-0185
6​
18-DFIU-00218-JG-01918-MG-0186
7​
18-DFIU-00218-JG-01918-MG-0187
8​
18-DFIU-00218-JG-01918-MG-0188
9​
18-DFIU-00318-JG-02018-MG-0196
Using your croostab query I will have a lot of colomns:



The max number of terminals for each JB is 5: So I need to have Terminal 1 to Terminal 5 columns and insert here the value of the terminal i.e.:


Tabella1 Tabella1

Junction BoxMulticable TagTerminal 1Terminal 2Terminal 3Terminal 4Terminal 5
18-JG-01718-MG-017123
18-JG-01918-MG-01845678
18-JG-02018-MG-0196
Is it possible?
 

Attachments

Last edited:
Then you need to generate a sequence number (1-5) for each group and pivot on the sequence number and take the First() value.
 
thanks Pat I got the point , Just I don't understand what do you mean take the First () valute, could you please make a sample?

Ok Finally Got It thanks for your support :)
 
Last edited:
In the crosstab, select First as the aggregate option.
 

Users who are viewing this thread

Back
Top Bottom