Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi
I am attempting to apply a custom column value only to the last group record, [I have a column named 'SiteDate' which could be used to determine the last record] before expanding my data view is as shown below with 'MinimumHours' a custom column
So if I expand the 'AllData' column the 'MinimumHours' value will be against each record
However I only require it to show against the last record in the group in this instance the line with a 'SiteDate' of 05/01/2025
Can this be achieved in PQ any assistance would be appreciated
Thanks
Solved! Go to Solution.
Hi @Richard_Halsall Could you try this please
let
GroupedData = Table.Group(Source, {"Technician"}, {{"AllData", each _, type table [SiteDate=date, MinimumHours=number]}}),
// Add Index to Each Group
AddIndex = Table.TransformColumns(GroupedData, {"AllData", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type)}),
// Identify Last Record
AddIsLastRecord = Table.TransformColumns(AddIndex, {"AllData", each Table.AddColumn(_, "IsLastRecord", (row) => row[Index] = Table.RowCount(_))}),
// Apply Custom Column for Last Record
AddCustomColumn = Table.TransformColumns(AddIsLastRecord, {"AllData", each Table.AddColumn(_, "CustomValue", (row) => if row[IsLastRecord] then row[MinimumHours] else null)}),
// Expand Back Data
ExpandedData = Table.ExpandTableColumn(AddCustomColumn, "AllData", {"SiteDate", "MinimumHours", "CustomValue"})
in
ExpandedData
Hi @Richard_Halsall Could you try this please
let
GroupedData = Table.Group(Source, {"Technician"}, {{"AllData", each _, type table [SiteDate=date, MinimumHours=number]}}),
// Add Index to Each Group
AddIndex = Table.TransformColumns(GroupedData, {"AllData", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type)}),
// Identify Last Record
AddIsLastRecord = Table.TransformColumns(AddIndex, {"AllData", each Table.AddColumn(_, "IsLastRecord", (row) => row[Index] = Table.RowCount(_))}),
// Apply Custom Column for Last Record
AddCustomColumn = Table.TransformColumns(AddIsLastRecord, {"AllData", each Table.AddColumn(_, "CustomValue", (row) => if row[IsLastRecord] then row[MinimumHours] else null)}),
// Expand Back Data
ExpandedData = Table.ExpandTableColumn(AddCustomColumn, "AllData", {"SiteDate", "MinimumHours", "CustomValue"})
in
ExpandedData
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.