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.
 
One of the people with more experience in writing the code directly may be able to tidy it up, but if it works , go with it.
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Ok decided to give a head start is it something like this
Book1
ABCDEFGHIJKLMNO
1Company_NameFilter_NameRequest IDPrint DateTransportDelivery DateAU_NumberRouteLocal#(If)Local#(If)_1ATM IDCurrencyDenominationCurrent_LoadFill_Method
2AFilt101/02/2024Truck04/02/2024123111 0609BUSDTwenties60000Manual
3AFilt102/02/2024Truck04/02/2024123111 0609BUSDFifties100000Manual
4AFilt103/02/2024Truck04/02/2024123111 0609BCash DepCash Dep0Manual
5BFilt204/02/2024Truck04/02/2024456222 0816CUSDTwenties70000Manual
6BFilt205/02/2024Truck04/02/2024456222 0816CUSDFifties100000Manual
7BFilt206/02/2024Truck04/02/2024456222 0816CCash DepCash Dep0Manual
8CFilt307/02/2024Truck04/02/2024789333 1242AUSDFifties140000Manual
9CFilt308/02/2024Truck04/02/2024789333 1242AUSDTwenties160000Manual
10CFilt309/02/2024Truck04/02/2024789333 1242ACash DepCash Dep0Manual
11DFilt410/02/2024Truck04/02/2024741444 1242HUSDTwenties50000Manual
12DFilt411/02/2024Truck04/02/2024741444 1242HUSDFifties100000Manual
13DFilt412/02/2024Truck04/02/2024741444 1242HCash DepCash Dep0Manual
14EFilt513/02/2024Truck05/02/2024852555 1670KUSDTwenties60000Auto
15FFilt614/02/2024Truck05/02/2024852666 0609BCash DepCash Dep0Auto
16BFilt715/02/2024Truck05/02/2024852777 0816CUSDFives5Auto
17DFilt816/02/2024Truck05/02/2024741888 1242HUSDOnes1Auto
18FFilt917/02/2024Truck05/02/2024963999 1670KUSDHundreds100Auto
19GFilt1018/02/2024Truck05/02/20247531010101456GUSDThousands1000Auto
Sheet1



Book1
ABCDEFGHIJKLMNOPQR
1Count.Company_NameCount.Filter_NameCount.Request IDCount.Print DateCount.TransportCount.Delivery DateCount.AU_NumberCount.RouteCount.Local#(If)Count.Local#(If)_1Count.ATM IDCount.Fill_MethodTwentiesFiftiesFivesOnesHundredsThousands
2AFilt101/02/2024Truck04/02/2024123111 0609BManual60000
3AFilt102/02/2024Truck04/02/2024123111 0609BManual100000
4BFilt204/02/2024Truck04/02/2024456222 0816CManual70000
5BFilt205/02/2024Truck04/02/2024456222 0816CManual100000
6BFilt715/02/2024Truck05/02/2024852777 0816CAuto5
7CFilt307/02/2024Truck04/02/2024789333 1242AManual140000
8CFilt308/02/2024Truck04/02/2024789333 1242AManual160000
9DFilt410/02/2024Truck04/02/2024741444 1242HManual50000
10DFilt411/02/2024Truck04/02/2024741444 1242HManual100000
11DFilt816/02/2024Truck05/02/2024741888 1242HAuto1
12EFilt513/02/2024Truck05/02/2024852555 1670KAuto60000
13FFilt917/02/2024Truck05/02/2024963999 1670KAuto100
14GFilt1018/02/2024Truck05/02/20247531010101456GAuto1000
Table1 (2)


As you can see in the line with Expanded Count you select all the columns you want to show so i removed Currency as you said you don't need it and Denomination is what we are grouping by so you can take that out also to prevent duplication

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Company_Name", type text}, {"Filter_Name", type text}, {"Request ID", Int64.Type}, {"Print Date", type date}, {"Transport", type text}, {"Delivery Date", type date}, {"AU_Number", Int64.Type}, {"Route", Int64.Type}, {"Local#(#)(If)", Int64.Type}, {"Local#(#)(If)_1", Int64.Type}, {"ATM ID", type text}, {"Currency", type text}, {"Denomination", type text}, {"Current_Load", Int64.Type}, {"Fill_Method", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Currency] = "USD")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Denomination"}, {{"Count", each _, type table [Company_Name=nullable text, Filter_Name=nullable text, Request ID=nullable number, Print Date=nullable date, Transport=nullable text, Delivery Date=nullable date, AU_Number=nullable number, Route=nullable number, #"Local#(#)(If)"=nullable number, #"Local#(#)(If)_1"=nullable number, ATM ID=nullable text, Currency=nullable text, Denomination=nullable text, Current_Load=nullable number, Fill_Method=nullable text]}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Company_Name", "Filter_Name", "Request ID", "Print Date", "Transport", "Delivery Date", "AU_Number", "Route", "Local#(#)(If)", "Local#(#)(If)_1", "ATM ID", "Current_Load", "Fill_Method"}, {"Count.Company_Name", "Count.Filter_Name", "Count.Request ID", "Count.Print Date", "Count.Transport", "Count.Delivery Date", "Count.AU_Number", "Count.Route", "Count.Local#(#)(If)", "Count.Local#(#)(If)_1", "Count.ATM ID", "Count.Current_Load", "Count.Fill_Method"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Count", List.Distinct(#"Expanded Count"[Denomination]), "Denomination", "Count.Current_Load")
in
    #"Pivoted Column"
I did have a type mismatch on route, local1 and local 2 they are text but then passed as numbers resulting in errors, but I fixed that
 
Upvote 0
See you're picking it up already (y) :biggrin:
Thank you again for your help. I am now going to try and make a module that can be used outside of excel so it can be a simple couple of clicks and a new file is produced.
 
Upvote 0
See you're picking it up already (y) :biggrin:
Okay so I took what you did and what little I learned on my own and tried to do the same thing with a different file and layout. Would you be willing to review this setup to see where I went wrong? I feel like I am so close...
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
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