Multiply values in column by a number if a date is detected as the column name in Power Query.

programsam

Board Regular
Joined
Feb 10, 2016
Messages
123
I'm attempting to have Power Query parse a list of columns and if the column has a month name as a header, I'd like to have it multiply the values in that column by 1.1 (10% increase). Here's my best attempt but it's giving me an error.

Excel Formula:
= Table.ReplaceValue(#"Renamed Columns", each try Value.Is(Date.From(_), type date), each (_) * 1.1, Replacer.ReplaceValue, {_})
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    months = List.Transform({1..12}, each Date.MonthName(#date(2023,_,1))),
    tcn = Table.ColumnNames(Source),
    MonthCols = List.Select(tcn, each List.Contains(months,_)),
    TransformOps = List.Accumulate(MonthCols, {}, (s,c)=> s & {{c, each _*1.1}}),
    Result = Table.TransformColumns(Source, TransformOps)
in
    Result

Book1
ABCDEFGHIJKLMN
1Column1Column2Column3JanuaryFebruaryMarchColumn1Column2Column3JanuaryFebruaryMarch
230222412392930222413.242.931.9
312728402131272844.02.214.3
426231142373226231146.240.735.2
5359381725413593818.727.545.1
633610164143361017.64.415.4
71519211882015192119.88.822.0
8534367313534367.734.13.3
9
Sheet2
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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