# Max value in list - Power Query



## Dan80

Hi All,

I have imported data into power query and i want to add custom column which states the latest date in the same table (I will then use this in a subsequent formula).  However, I can't for the life of me work out how to do it.  I am trying to use "List.Max" but the column just returns errors.

Not sure how, but I managed to create a query which returns the correct value but I don't know how to reference the value in the subsequent formula.  Any help would be greatly appreciated!  Thanks,

Dan


----------



## ralliartur

You are looking for this solution:

AddCustom = Table.AddColumn(ChangedType, "Custom", each List.Max(ChangedType[a]))

Explanation:
ChangedType - name of previous step in your query
[a] - name of column to look for max

You can add this in advanced editor


----------



## Dan80

Ralliartur - you are seriously brilliant, thanks so much for your help!  

Where did you learn this 'stuff'?  As you can tell I am new to all things 'Power' - did you pick it up through using 'Power' or is the 'coding' similar to something else?  I am finding this stuff incredibly useful and would like to train up on it but in a more structured way to what I am doing now which is, have a go, when stuck, go on this forum.  Thanks again, first class!

dan


----------



## ralliartur

Thanks,

I've learned from books and blogs (and my own work):

Books: 
1. Power Query for Power BI and Excel
2. M Is for (Data) Monkey: A Guide to the M Language in Excel Power Query

Blogs:
1. Chris Webb - https://blog.crossjoin.co.uk/category/power-query/
2. Ken Plus - The Ken Puls (Excelguru) Blog (useful patterns -> https://www.powerquery.training/patterns/)
and other blogs where Power BI is mentioned


In most cases you can do all transformations by only using ribbon, but if you want to do more you need to get familiar with M code, and you'll need to learn it from scratch. This is the place where blogs are relevant - you'll find really cool stuff there. Good luck for you.


----------

