How to split one row into multiple rows based on specific criteria

Mcansi

New Member
Joined
Jul 25, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello - I'm attempting to split one row into multiple based on the number of years. Example below:

This is the source data. The dates are for every month in 2022, 2023, and 2024 but I've condensed it keep it simple.

IDAccount1/31/20222/28/20221/31/20232/28/20231/31/20242/28/2024
12341111100100200200300300
123522229595105105115115

Below is what I hope to achieve:

IDAccountYearJanFeb
123411112022100100
123411112023200200
123411112024300300
1235222220229595
123522222023105105
123522222024115115

I'd prefer to use index match formula somehow but am having a hard time getting it to work. Any help would be much appreciated 🙂
 
Last edited by a moderator:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
With Power Query, unpivot your data so that you can repivot into desired format
Book5
ABCDEFGHIJK
1IDAccount1/31/20222/28/20221/31/20232/28/20231/31/20242/28/2024
212341111100100200200300300<--Orig Data
3123522229595105105115115
4
5
6IDAccountValueYearMonth NameSum of ValueMonth Name
7123411111002022JanuaryIDAccountYearJanuaryFebruary
8123411111002022February123411112022100100
9123411112002023January2023200200
10123411112002023February2024300300
11123411113002024January1235222220229595
12123411113002024February2023105105
1312352222952022January2024115115
1412352222952022February
15123522221052023January
16123522221052023February
17123522221152024January
18123522221152024February
Sheet1


Mcode to unpivot

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ID", "Account"}, "Attribute", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}}),
    #"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([Attribute]), Int64.Type),
    #"Inserted Month Name" = Table.AddColumn(#"Inserted Year", "Month Name", each Date.MonthName([Attribute]), type text),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Month Name",{"Attribute"})
in
    #"Removed Columns"

Pivot Table set up
 

Attachments

  • Screenshot 2022-07-25 144526.jpg
    Screenshot 2022-07-25 144526.jpg
    38.8 KB · Views: 16
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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