Forum Discussion
docs
10 months agoFrequent Visitor
Power BI Grouped Rows
I have created a grouped row which shows all notes related to an object id but I only want the last 6 notes created to be shown in this grouped row. Is there any filters I can put in place to do this...
- 10 months ago
Hi, ideally you would do this before grouping the rows. but if you wanted to add after your last step, you can also use below logic. It's tested working on my end.
let SplitNotes = Table.ExpandListColumn( Table.TransformColumns(Grouped Rows, {"Combined Notes", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv)}), "Combined Notes" ), AddDate = Table.AddColumn(SplitNotes, "NoteDate", each Date.FromText(Text.Start([Combined Notes], 10)), type date), Sorted = Table.Sort(AddDate, {{"objectid", Order.Ascending}, {"NoteDate", Order.Descending}}), Grouped = Table.Group(Sorted, {"objectid"}, {{"Top6Notes", each Table.FirstN(_, 6), type table [objectid=nullable number, Combined Notes=nullable text, NoteDate=nullable date]}}), CombineNotes = Table.TransformColumns( Grouped, {"Top6Notes", each Text.Combine([Combined Notes], "#(lf)"), type text} ) in CombineNotes
ivana_tomekova
10 months agoAdvocate II
Hi... After you sorted your rows and before creating concatenated text, you can add column, which will rank the notes from 1 to n over the objectid... then remove all that are bigger than 6 and then concatenate 😉
How to ingest that nested ranking, you can check here: https://blog.crossjoin.co.uk/2015/05/11/nested-calculations-in-power-query/