Need to Pull from CSV rows into new sheet columns

edjohn20

New Member
Joined
Mar 5, 2024
Messages
26
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have attached the images sample 1 and sample 2. My data comes to me via sample 1 in row form however I have to import data via format sample 2. I only need the USD lines and cash dep lines are ignored.

sample 1.png
you can see location 609b gets 20's and 50's but it needs to be moved to this type of formatting

sample 2.png
and though the LOC ids aren't the same (i just used two different files) you can see how I need all the data for one LOC on one line.

Does anyone have an easy way to do this. I am having to manually create this sheet daily and it is killing time.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi, are these from 2 separate work files, or are they from different sheets within the same workbook ?

Its unclear how you "import" sample 2 data and where you put it - as clearly it looks like you overwrite sample 1 for now ?

Please provide a bit more detail in term of your process.
cheers
Rob
 
Upvote 0
Book1
ABCDEFGH
1LOCCurrencyDenominationCurCount.LOCTwentiesFifties
20609BUSDTwenties600000609B60000100000
30609BUSDFifties1000000816C70000100000
40609BCash Dep Cash Dep 01242A160000140000
50816CUSDTwenties700001242H50000100000
60816CUSDFifties1000001670K60000
70816CCash Dep Cash Dep 0
81242AUSDFifties140000
91242AUSDTwenties160000
101242ACash Dep Cash Dep 0
111242HUSDTwenties50000
121242HUSDFifties100000
131242HCash Dep Cash Dep 0
141670KUSDTwenties60000
Sheet1


Using these steps
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"LOC", type text}, {"Currency", type text}, {"Denomination", type text}, {"Cur", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Denomination] <> "Cash Dep ")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Currency"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Denomination"}, {{"Count", each _, type table [LOC=nullable text, Denomination=nullable text, Cur=nullable number]}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"LOC", "Cur"}, {"Count.LOC", "Count.Cur"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Count", List.Distinct(#"Expanded Count"[Denomination]), "Denomination", "Count.Cur")
in
    #"Pivoted Column"
 
Upvote 0
But in case you want to use 3 quick formulas to copy down the rows you could do this also:

Book1
JKLMNOPQRS
1LOCCurrency Denomine CurDenominationCurValue20Value50Value100
2 0609BUSDTwenties6000060000  
3 0609BUSDFifties100000 100000 
4 0609BCash DepCash Dep0   
5 0816CUSDTwenties7000070000  
6 0816CUSDFifties100000 100000 
7 0816CCash DepCash Dep0   
8 1242AUSDFifties140000 140000 
9 1242AUSDTwenties160000160000  
10 1242ACash DepCash Dep0   
11 1242HUSDTwenties5000050000  
12 1242HUSDFifties100000 100000 
13 1242HCash DepCash Dep0   
14 1670KUSDTwenties6000060000  
15
Sheet1
Cell Formulas
RangeFormula
P2:P14P2=IF(M2="Twenties",N2,"")
Q2:Q14Q2=IF(M2="Fifties",N2,"")
R2:R14R2=IF(M2="Hundreds",N2,"")
 
Upvote 0
Sorry, ignore my answer, as I realised you are combining rows also.. Kerrys looks like what you need.

sorry
Rob
 
Upvote 0
Hi, are these from 2 separate work files, or are they from different sheets within the same workbook ?

Its unclear how you "import" sample 2 data and where you put it - as clearly it looks like you overwrite sample 1 for now ?

Please provide a bit more detail in term of your process.
cheers
Rob
these are two separate file. I get a csv with data in rows and I create a new file xls with date in columns from merged row data
 
Upvote 0
Book1
ABCDEFGH
1LOCCurrencyDenominationCurCount.LOCTwentiesFifties
20609BUSDTwenties600000609B60000100000
30609BUSDFifties1000000816C70000100000
40609BCash Dep Cash Dep 01242A160000140000
50816CUSDTwenties700001242H50000100000
60816CUSDFifties1000001670K60000
70816CCash Dep Cash Dep 0
81242AUSDFifties140000
91242AUSDTwenties160000
101242ACash Dep Cash Dep 0
111242HUSDTwenties50000
121242HUSDFifties100000
131242HCash Dep Cash Dep 0
141670KUSDTwenties60000
Sheet1


Using these steps
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"LOC", type text}, {"Currency", type text}, {"Denomination", type text}, {"Cur", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Denomination] <> "Cash Dep ")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Currency"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Denomination"}, {{"Count", each _, type table [LOC=nullable text, Denomination=nullable text, Cur=nullable number]}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"LOC", "Cur"}, {"Count.LOC", "Count.Cur"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Count", List.Distinct(#"Expanded Count"[Denomination]), "Denomination", "Count.Cur")
in
    #"Pivoted Column"
Book1
ABCDEFGH
1LOCCurrencyDenominationCurCount.LOCTwentiesFifties
20609BUSDTwenties600000609B60000100000
30609BUSDFifties1000000816C70000100000
40609BCash Dep Cash Dep 01242A160000140000
50816CUSDTwenties700001242H50000100000
60816CUSDFifties1000001670K60000
70816CCash Dep Cash Dep 0
81242AUSDFifties140000
91242AUSDTwenties160000
101242ACash Dep Cash Dep 0
111242HUSDTwenties50000
121242HUSDFifties100000
131242HCash Dep Cash Dep 0
141670KUSDTwenties60000
Sheet1


Using these steps
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"LOC", type text}, {"Currency", type text}, {"Denomination", type text}, {"Cur", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Denomination] <> "Cash Dep ")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Currency"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Denomination"}, {{"Count", each _, type table [LOC=nullable text, Denomination=nullable text, Cur=nullable number]}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"LOC", "Cur"}, {"Count.LOC", "Count.Cur"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Count", List.Distinct(#"Expanded Count"[Denomination]), "Denomination", "Count.Cur")
in
    #"Pivoted Column"
functionally this looks correct but the files are not in the same sheet. it is two different workbook. For simplicity sake how would the code look if data is coming from "SAMPLE1" and rearranged into "SAMPLE2"

sample1 being original CSV file and sample2 being the new file
 
Upvote 0
Book1
ABCDEFGH
1LOCCurrencyDenominationCurCount.LOCTwentiesFifties
20609BUSDTwenties600000609B60000100000
30609BUSDFifties1000000816C70000100000
40609BCash Dep Cash Dep 01242A160000140000
50816CUSDTwenties700001242H50000100000
60816CUSDFifties1000001670K60000
70816CCash Dep Cash Dep 0
81242AUSDFifties140000
91242AUSDTwenties160000
101242ACash Dep Cash Dep 0
111242HUSDTwenties50000
121242HUSDFifties100000
131242HCash Dep Cash Dep 0
141670KUSDTwenties60000
Sheet1


Using these steps
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"LOC", type text}, {"Currency", type text}, {"Denomination", type text}, {"Cur", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Denomination] <> "Cash Dep ")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Currency"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Denomination"}, {{"Count", each _, type table [LOC=nullable text, Denomination=nullable text, Cur=nullable number]}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"LOC", "Cur"}, {"Count.LOC", "Count.Cur"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Count", List.Distinct(#"Expanded Count"[Denomination]), "Denomination", "Count.Cur")
in
    #"Pivoted Column"
I would also like to have the functionality that if the denom should change to TENS or HUNDREDS or whatever is listed that a column is created. It may not always be only two denominations. It could be as much as 5. I should have led with all this information.
 
Upvote 0
Code looks exactly the same as in power query when you click on "close & Load to" you select where you want the new data to be loaded , if its a new sheet select that option.
The code only filters to remove "Cash Dep" and then puts remaing data, your Denominations into whatever groups are there in your sheet.
If you had example of csv file the data could be loaded directly from that into PQ and processed,
1711034332512.png

Book1
ABCD
1LOCCurrencyDenominationCur
2 0609BUSDTwenties60000
3 0609BUSDFifties100000
4 0609BCash DepCash Dep0
5 0816CUSDTwenties70000
6 0816CUSDFifties100000
7 0816CCash DepCash Dep0
8 1242AUSDFifties140000
9 1242AUSDTwenties160000
10 1242ACash DepCash Dep0
11 1242HUSDTwenties50000
12 1242HUSDFifties100000
13 1242HCash DepCash Dep0
14 1670KUSDTwenties60000
15 0609BCash DepCash Dep0
16 0816CUSDFives5
17 1242HUSDOnes1
18 1670KUSDHundreds100
191456GUSDThousands1000
Sheet1



Book1
ABCDEFG
1Count.LOCTwentiesFiftiesFivesOnesHundredsThousands
2 0609B60000100000
3 0816C700001000005
4 1242A160000140000
5 1242H500001000001
6 1670K60000100
71456G1000
Table1
 
Upvote 0
Code looks exactly the same as in power query when you click on "close & Load to" you select where you want the new data to be loaded , if its a new sheet select that option.
The code only filters to remove "Cash Dep" and then puts remaing data, your Denominations into whatever groups are there in your sheet.
If you had example of csv file the data could be loaded directly from that into PQ and processed,
View attachment 108796
Book1
ABCD
1LOCCurrencyDenominationCur
2 0609BUSDTwenties60000
3 0609BUSDFifties100000
4 0609BCash DepCash Dep0
5 0816CUSDTwenties70000
6 0816CUSDFifties100000
7 0816CCash DepCash Dep0
8 1242AUSDFifties140000
9 1242AUSDTwenties160000
10 1242ACash DepCash Dep0
11 1242HUSDTwenties50000
12 1242HUSDFifties100000
13 1242HCash DepCash Dep0
14 1670KUSDTwenties60000
15 0609BCash DepCash Dep0
16 0816CUSDFives5
17 1242HUSDOnes1
18 1670KUSDHundreds100
191456GUSDThousands1000
Sheet1



Book1
ABCDEFG
1Count.LOCTwentiesFiftiesFivesOnesHundredsThousands
2 0609B60000100000
3 0816C700001000005
4 1242A160000140000
5 1242H500001000001
6 1670K60000100
71456G1000
Table1
ok, that makes sense. Where would I save the code you posted above? Would that be a macro or injected somewhere else?
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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