Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi
Can anyone please tell me how to copy entire column data and paste that values in another empty column based on current month name.
This is how my table looks now. Since we are in September month, Other income value has to be copied in September and other column values i need to enter manual data.
I have fetched current month + 11 months dynamically and appended those to this table where in im trying to copy and paste.
Please give me some solution.
Solved! Go to Solution.
@GokilaRaviraj , Try using below m-code
let
// Load your data source
Source = Excel.CurrentWorkbook(){[Name="YourTableName"]}[Content],
// Add a column with the current month name
AddCurrentMonth = Table.AddColumn(Source, "CurrentMonth", each Date.ToText(DateTime.LocalNow(), "MMMM"), type text),
// Duplicate the "Other income" column
DuplicateOtherIncome = Table.AddColumn(AddCurrentMonth, "CurrentMonthData", each [Other income]),
// Add a conditional column to copy data based on the current month
AddConditionalColumn = Table.AddColumn(DuplicateOtherIncome, "UpdatedColumn", each if [CurrentMonth] = "September" then [CurrentMonthData] else null),
// Remove unnecessary columns
RemoveColumns = Table.RemoveColumns(AddConditionalColumn,{"CurrentMonth", "CurrentMonthData"}),
// Rename the updated column to the current month name
RenameColumn = Table.RenameColumns(RemoveColumns, {{"UpdatedColumn", Date.ToText(DateTime.LocalNow(), "MMMM")}})
in
RenameColumn
Proud to be a Super User! |
|
Hi @GokilaRaviraj, check this:
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTI0ABJQFKsTrZQEZBihiSUDGcbIYrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Company Name" = _t, #"Other Income" = _t, september = _t, october = _t, november = _t]),
// You can probably delete this step with your data.
ReplaceBlankToNull = Table.TransformColumns(Source, {}, each if _ = "" then null else _),
ChangedType = Table.TransformColumnTypes(ReplaceBlankToNull,{{"Other Income", type number}}),
ReplacedCurrentMonth = Table.ReplaceValue(ChangedType,
each null,
each [Other Income],
Replacer.ReplaceValue,
{Text.Lower(DateTime.ToText(DateTime.FixedLocalNow(), "MMMM", "en-US"))} )
in
ReplacedCurrentMonth
@GokilaRaviraj , Try using below m-code
let
// Load your data source
Source = Excel.CurrentWorkbook(){[Name="YourTableName"]}[Content],
// Add a column with the current month name
AddCurrentMonth = Table.AddColumn(Source, "CurrentMonth", each Date.ToText(DateTime.LocalNow(), "MMMM"), type text),
// Duplicate the "Other income" column
DuplicateOtherIncome = Table.AddColumn(AddCurrentMonth, "CurrentMonthData", each [Other income]),
// Add a conditional column to copy data based on the current month
AddConditionalColumn = Table.AddColumn(DuplicateOtherIncome, "UpdatedColumn", each if [CurrentMonth] = "September" then [CurrentMonthData] else null),
// Remove unnecessary columns
RemoveColumns = Table.RemoveColumns(AddConditionalColumn,{"CurrentMonth", "CurrentMonthData"}),
// Rename the updated column to the current month name
RenameColumn = Table.RenameColumns(RemoveColumns, {{"UpdatedColumn", Date.ToText(DateTime.LocalNow(), "MMMM")}})
in
RenameColumn
Proud to be a Super User! |
|
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
8 | |
8 | |
7 |
User | Count |
---|---|
17 | |
13 | |
7 | |
6 | |
6 |