Forum Discussion
kirvis
Helper I
6 years agoCreate bins for subcategories based on MIN and MAX values
Hi all, I am working on a project for which I would like to create bins based on the MAX and MIN of a value within a subset. The dataset has 3 columns: Cell ID Gene ID Value I want t...
- 6 years ago
Hi kirvis
you have to turn the query into a function and apply it on the grouped data.
Please see file attached.
ImkeF
Community Champion
6 years agoHi kirvis
please check this query:
let
Source = Excel.CurrentWorkbook(){[Name="Expression_FACT"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"GeneID", Int64.Type}, {"Cell ID", Int64.Type}, {"Value", type number}}),
ListOfValues = List.Buffer(#"Changed Type"[Value]),
Min = List.Min(ListOfValues),
Max = List.Max(ListOfValues),
Increment = (Max - Min) / 10,
Buckets = List.Transform({1..10}, each [Index = _, Value = Min + (_ * Increment) ] ),
#"Converted to Table" = Table.FromList(Buckets, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Index", "Value"}, {"Index", "Value"}),
Custom1 = #"Expanded Column1" & #"Changed Type",
#"Sorted Rows" = Table.Buffer(Table.Sort(Custom1,{{"Value", Order.Descending}, {"Index", Order.Descending}})),
#"Filled Down" = Table.FillDown(#"Sorted Rows",{"Index"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([GeneID] <> null))
in
#"Filtered Rows"
This is not the fastest operation one can run...
kirvis
Helper I
6 years agoHi Imke,
Thanks for your response. The query seems to work like a charm (and is quite fast as well).
However, I realize that I might not have made myself completely clear in my original post: I would like to do exactly this, but then for each GeneID separately. In your query, you determine the MIN and MAX of all values combined, so of all GeneIDs together.
Is there an easy way to do exactly what you have done, but then grouped per GeneID?
Thanks,
Kirvis