Forum Discussion
Sherly26
Mar 11, 2023Copper Contributor
Formula to pull out the most recent data
Dear all, I would like to ask for formula in excel which I can use if I would like to pull out the most recent data that I have. I have a spreadsheet containing 3 year of data – 2006, 2009 and 2012...
- Mar 11, 2023
PQ variant
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Unpivoted Other Columns" = Table.UnpivotOtherColumns( Source, {"Department"}, "Year", "Number"), declareTypes = Table.TransformColumnTypes( #"Unpivoted Other Columns", { {"Year", Int64.Type}, {"Number", Int64.Type} }), #"Sorted Rows" = Table.Sort( declareTypes, { {"Department", Order.Ascending}, {"Year", Order.Descending} }), fixInMemory = Table.AddIndexColumn( #"Sorted Rows", "Index", 0, 1, Int64.Type), removeDuplicates = Table.Distinct(fixInMemory, {"Department"}), removeIndex = Table.SelectColumns( removeDuplicates, {"Department", "Number", "Year"}) in removeIndex
HansVogelaar
Mar 11, 2023MVP
The attached workbook uses the LOOKUP function.
Sherly26
Mar 18, 2023Copper Contributor
Thank you for this. I look at what it means by 1E+307 -> it means that it is a value to get the biggest number - is that correct? If yes, then I don't think I will be able to use them - because there is possibility I have lower number in a recent data.
Thank you.
- HansVogelaarMar 18, 2023MVP
1E+307 is a number larger than any you will have in your data. Have you tried it?
- Sherly26Mar 18, 2023Copper ContributorYes I have tried that - but it does not work for some row where I have lower number of recent data. For example in case E - I have 2006 (5); 2009 (2) - it bring to 5 while I want them to be 2.
- HansVogelaarMar 18, 2023MVP
It works correctly for me - see Department E.
Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?