This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Dear All,
I have the following table:
| Date | Cost category | Bdg |
| 01/01/2023 | Consultants | 5000 |
| 01/01/2023 | Software | 12000 |
| 01/01/2023 | Machinery | 5000 |
| 01/01/2023 | Insurance | 6000 |
| 01/01/2023 | Cleaning | 8000 |
| 01/01/2023 | Maintenance | 9000 |
| 01/01/2023 | Taxes | 10000 |
I want to automatically create the same exact rows till the end of the year.
In other words, create repetitions of column B and C, but column A should complete the months till 01/12/2023.
Is there any way to achieve this?
Thank you very much
gianmarco
Hi,
This M code works
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Added Custom" = Table.ExpandListColumn(Table.AddColumn(Source, "Month number", each {1..12}),"Month number"),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each Date.AddMonths([Date],[Month number]-1), type date),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Date", "Month number"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Bdg", Int64.Type}, {"Custom", type date}})
in
#"Changed Type"
Hope this helps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjAyNjJR0l5/y84tKcksS8kmIgz9TAwEApVgdNTXB+Wkl5YlEqkGlohFWFb2JyRmZealElTjM8gdYUJeYlgwwxw6rCOSc1MS8zLx3ItMBhSWZeSWoe1BBLrGpCEitSQR4xNABLxwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Cost category" = _t, Bdg = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Bdg", Currency.Type}}),
Months = {1..12},
#"Converted to Table" = Table.FromList(Months, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each Table.ReplaceValue(#"Changed Type",#date(2023, 1, 1),#date(2023, [Column1], 1),Replacer.ReplaceValue,{"Date"})),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Date", "Cost category", "Bdg"}, {"Date", "Cost category", "Bdg"})
in
#"Expanded Custom"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 30 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 65 | |
| 53 | |
| 31 | |
| 23 | |
| 23 |