Exporting data from old table to new table

Status
Not open for further replies.

kirkley08

New Member
Joined
Mar 29, 2023
Messages
20
Office Version
  1. 2021
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone, good day!

I'm trying to convert/export the data from my "Database" to the new excel table (different table format).

From this:
This.xlsx
ABCEFGHIJKLMN
1
2Reward and Fine List
3NoWeekDayStaffR/FArticleDesc.AmountConsecutive 3AmountConsecutive 5Amount
41W1404.01JohnR12.1.1Good Attitude100    
52W1404.01LucyR12.1.1Good Attitude100    
63W1404.01KobeF12.3.2Late100    
74W1404.01LawrenceR12.1.1Good Attitude100    
85W1404.01KobeR12.1.1Good Attitude100    
96W1404.01KobeR22.1.1Good Attitude100    
107W1404.01LawrenceR22.1.1Good Attitude100    
118W1504.03KobeR32.1.1Good Attitude1001600  
129W1504.03LawrenceR32.1.1Good Attitude1001600  
1310W1504.03BabyF12.3.2Late100    
1411W1504.03JohnF12.3.2Late100    
1512W1504.03KobeR42.1.1Good Attitude100    
1613W1504.03JohnR12.1.1Good Attitude100    
1714W1504.04BabyR12.1.1Good Attitude100    
1815W1504.04KobeR52.1.1Good Attitude100  11000
Database
Cell Formulas
RangeFormula
K4:K18K4=IFERROR(IF(AND(MOD(G4,3)=0,G4<>0),INT(G4/3),""),"")
L4:L18L4=IF(COUNTBLANK(K4)=1,"",600)
M4:M18M4=IFERROR(IF(AND(MOD(G4,5)=0,G4<>0),INT(G4/5),""),"")
N4:N18N4=IF(COUNTBLANK(M4)=1,"",1000)
A4:A18A4=IF(COUNTA(E4)=1,COUNTA($E$3:E3),"")
G4:G18G4=IF(COUNTA(E4)=0,"",IF(COUNTIFS($D$2:D4,D4)=1,1,IF(D4=D3,G3+1,IF(AND(E4=E3,F4<>F3),1,IF(AND(E4<>E3,MAX(IF($D$2:D3=D4,$A$2:A3))>=MAX(IF($D$2:D3=(E4&VLOOKUP(F4,$P$1:$Q$2,2,)),$A$2:A3))),VLOOKUP(MAX(IF($D$2:D3=D4,$A$2:A3)),$A$2:G3,7,)+1,1)))))
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
_FilterDatabase=Database!$A$3:$N$103G4:G18


to this new table format:
This.xlsx
ABCDEFGHIJ
1
2Reward and Fine List
3NoWDStaff.DescriptionFineReward
4
532W1404.01R1John100
62.1.1
7Good Attitude
832W1404.01R1Lucy100
92.1.1
10Good Attitude
11
12
13
New Table



Other than using "lookup" formula, is there any other way to convert/export it faster? if the records are 500s or 1000s, it will be time consuming to add the boxes in new table and applying the lookup formula.

Thanks!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I don't think it is possible to have tables with merged cells. And, in general merged cells is not considered an excel best practice.

But, to look into your question, yes, it can be done. But you have data in your expectations that are not present in your initial table. what cells are the yellow highlighted data located in?
mr excel questions 22.xlsm
EFGHIJKLMN
22NoWDStaff.DescriptionFineReward
23
2432W1445017R1John100
252.1.1
26Good Attitude
Sheet3
 
Upvote 0
I don't think it is possible to have tables with merged cells. And, in general merged cells is not considered an excel best practice.

But, to look into your question, yes, it can be done. But you have data in your expectations that are not present in your initial table. what cells are the yellow highlighted data located in?
mr excel questions 22.xlsm
EFGHIJKLMN
22NoWDStaff.DescriptionFineReward
23
2432W1445017R1John100
252.1.1
26Good Attitude
Sheet3
Ohh yeah sorry my bad, for the second table I forgot to change the order number when making minisheet. Here's the correct one for expected table.

This.xlsx
ABCDEFGHIJ
1
2Reward and Fine List
3NoWDStaff.DescriptionFineReward
4
51W1404.01R1John100
62.1.1
7Good Attitude
82W1404.01R1Lucy100
92.1.1
10Good Attitude
11
12
13
New Table


Yellow highlighted cells:
1. E24 : Initial Table column A:A
2. H24 : Initial Table column F:F
3. H26 : Initial Table column I:I
4. N24 : Initial Tabel column J:J << for this one I was thinking if it can also read the condition if R then will go to "Reward", if F then to "Fine". If it's not possible then I will just divide column J:J in initial table to two (one for reward, one for fine)
 
Upvote 0
thanks for theupdated information.
Just curious, is this for a report or something?
You only have one value in each of the 2nd and 3rd rows. If you want a table, you can't have related data of one row on another.
 
Upvote 0
For my question about H24, is it concatenated F:F & G:G, where does the number come from, if not G:G?
 
Upvote 0
thanks for theupdated information.
Just curious, is this for a report or something?
You only have one value in each of the 2nd and 3rd rows. If you want a table, you can't have related data of one row on another.
Yes this is for a report, but the report need to be in the form of the expected table.
You only have one value in each of the 2nd and 3rd rows. If you want a table, you can't have related data of one row on another. << you mean in order to make a table, the data from the initial table need to be standalone value, can't have it to be related/read the conditions in other rows? Is that correct?
 
Upvote 0
For my question about H24, is it concatenated F:F & G:G, where does the number come from, if not G:G?
yes it's concatenated. but if my understanding of "can't have related data of one row on another" is correct, means I need to make another column for concatenated value first before I want it to be exported to expected table right?
 
Upvote 0
no, i'm talking about excel tables. in databases you can have related data in other tables. the 2nd and 3rd row are essentially related data (to whatever key is in the first row)... but spreadsheet excel doesn't workthat way. It can with Power Pivot, I think (I am not expert on that, i'm barely well advanced in excel formulas).

But, here is a stab at it. I did not concatenate G and H in this, and that would actually complicate this formula even more so. This doesn't even have H being mapped, I'll post an update in a minute, but you can peek at this and see if it satisfies (Look at the green, I'll explain what you need to do to fit it into your workbook as well).


mr excel questions 22.xlsm
ABCDEFGHIJKLMN
1
2Reward and Fine List
3NoWeekDayStaffR/FArticleDesc.AmountConsecutive 3AmountConsecutive 5Amount
41W1445017JohnR12.1.1Good Attitude100    
52W1445017LucyR22.1.1Good Attitude100    
61234567891011121314
74W1445017LawrenceR#N/A2.1.1Good Attitude100    
85W1445017KobeR#N/A2.1.1Good Attitude100    
20
21Reward and Fine List
22NoWDStaff.DescriptionFineReward
23
2432W1445017R1John100
252.1.1
26Good Attitude
2711W1445017R John   100
281   2.1.1      
291   Good Attitude      
3022W1445017R Lucy   100
312   2.1.1      
322   Good Attitude      
3331236 5   10
343   8      
353   9      
3644W1445017R Lawrence   100
374   2.1.1      
384   Good Attitude      
kirkley08
Cell Formulas
RangeFormula
K4:K5,K7:K8K4=IFERROR(IF(AND(MOD(G4,3)=0,G4<>0),INT(G4/3),""),"")
L4:L5,L7:L8L4=IF(COUNTBLANK(K4)=1,"",600)
M4:M5,M7:M8M4=IFERROR(IF(AND(MOD(G4,5)=0,G4<>0),INT(G4/5),""),"")
N4:N5,N7:N8N4=IF(COUNTBLANK(M4)=1,"",1000)
A4:A5,A7:A8A4=IF(COUNTA(E4)=1,COUNTA($E$3:E3),"")
G4:G5,G7:G8G4=IF(COUNTA(E4)=0,"",IF(COUNTIFS($D$2:D4,D4)=1,1,IF(D4=D3,G3+1,IF(AND(E4=E3,F4<>F3),1,IF(AND(E4<>E3,MAX(IF($D$2:D3=D4,$A$2:A3))>=MAX(IF($D$2:D3=(E4&VLOOKUP(F4,$E$20:$F$21,2,)),$A$2:A3))),VLOOKUP(MAX(IF($D$2:D3=D4,$A$2:A3)),$A$2:G3,7,)+1,1)))))
D27:D38D27=ROUNDDOWN((ROW(E27)-27)/3,0)+1
E27:N38E27=IFERROR(INDEX($A$4:$N$8,ROUNDDOWN((ROW(E27)-27)/3,0)+1, SWITCH(10*(MOD((ROW(E27)-27),3)) + MOD((COLUMN(E27)-5),10)+1,1,1,2,2,3,3,4,6,6,5,10,10,14,8,24,9)),"")
 
Upvote 0
Okay, this has the second part of that concatenated value in the next cell. If that isn't what your managment needs then you need to insert an IF to concatenate. Maybe you can see how I built the INDEX/SWITCH formula to figure out how to contatenate that in there (would append an "& ... to the end of the entire formula.

Now, to get the formula working in your workbook. I hope you are using 2021, as I'm not sure if SWITCH is available other than 2021 and 365 (and I'm not sure about 2021).

In the formulas where you see the ROW and COLUMN functions. I'm subtracting the row or column number from the top left cell the formula begins in. So, if you paste the formula into A2, the ROW component would be (ROW(A2)-2), and the COLUMN component would be (COLUMN(A2)-1).

(Edit: I have pasted this twice, hopefully to get borders)

mr excel questions 22.xlsm
ABCDEFGHIJKLMNO
1
2Reward and Fine List
3NoWeekDayStaffR/FArticleDesc.AmountConsecutive 3AmountConsecutive 5Amount
41W1445017JohnR12.1.1Good Attitude100    
52W1445017LucyR22.1.1Good Attitude100    
61234567891011121314
74W1445017LawrenceR#N/A2.1.1Good Attitude100    
85W1445017KobeR#N/A2.1.1Good Attitude100    
96W1445017KobeR#N/A2.1.1Good Attitude100    
107W1445017LawrenceR#N/A2.1.1Good Attitude100    
118W1545019KobeR#N/A2.1.1Good Attitude100    
129W1545019LawrenceR#N/A2.1.1Good Attitude100    
1310W1545019BabyF#N/A2.3.2Late100    
1411W1545019JohnF#N/A2.3.2Late100    
1512W1545019KobeR#N/A2.1.1Good Attitude100    
1613W1545019JohnR#N/A2.1.1Good Attitude100    
1714W1545020BabyR#N/A2.1.1Good Attitude100    
1815W1545020KobeR#N/A2.1.1Good Attitude100    
19
20
21Reward and Fine List
22NoWDStaff.DescriptionFineReward
23
2432W1445017R1John100
252.1.1
26Good Attitude
2711W1445017R1John   100
281   2.1.1      
291   Good Attitude      
3022W1445017R2Lucy   100
312   2.1.1      
322   Good Attitude      
333123675   10
343   8      
353   9      
3644W1445017R Lawrence   100
374   2.1.1      
384   Good Attitude      
39
kirkley08
Cell Formulas
RangeFormula
K4:K5,K7:K18K4=IFERROR(IF(AND(MOD(G4,3)=0,G4<>0),INT(G4/3),""),"")
L4:L5,L7:L18L4=IF(COUNTBLANK(K4)=1,"",600)
M4:M5,M7:M18M4=IFERROR(IF(AND(MOD(G4,5)=0,G4<>0),INT(G4/5),""),"")
N4:N5,N7:N18N4=IF(COUNTBLANK(M4)=1,"",1000)
A4:A5,A7:A18A4=IF(COUNTA(E4)=1,COUNTA($E$3:E3),"")
G4:G5,G7:G18G4=IF(COUNTA(E4)=0,"",IF(COUNTIFS($D$2:D4,D4)=1,1,IF(D4=D3,G3+1,IF(AND(E4=E3,F4<>F3),1,IF(AND(E4<>E3,MAX(IF($D$2:D3=D4,$A$2:A3))>=MAX(IF($D$2:D3=(E4&VLOOKUP(F4,$E$20:$F$21,2,)),$A$2:A3))),VLOOKUP(MAX(IF($D$2:D3=D4,$A$2:A3)),$A$2:G3,7,)+1,1)))))
D27:D38D27=ROUNDDOWN((ROW(E27)-27)/3,0)+1
E27:N38E27=IFERROR(INDEX($A$4:$N$8,ROUNDDOWN((ROW(E27)-27)/3,0)+1, SWITCH(10*(MOD((ROW(E27)-27),3)) + MOD((COLUMN(E27)-5),10)+1,1,1,2,2,3,3,4,6,5,7,6,5,10,10,14,8,24,9)),"")
 
Upvote 1
CORRECTION TO EARLIER STATEMENT:
no, i'm talking about excel tables. in databases you can have related data in other tables. the 2nd and 3rd row are essentially related data (to whatever key is in the first row)
I meant you can't have related data in other ROWS. each row in an excel table is its own record. I have not seen any excel tables where a prior row is linked to a subsequent row.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,876
Messages
6,181,521
Members
453,050
Latest member
Obil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top