Forum Discussion
PBIBeginner2022
4 years agoHelper III
Add column with sixth previous month
Hi everyone, I need to add a new custom column with sixth previous month in Power Query. I thinked to use that formula but it don't function : = Table.AddColumn(#"Type modifié", "Extract_mont...
jennratten
4 years agoSuper User
Here you are...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyirNzNE1MlKK1SGanUeInZuYCWMmlhUhRIuKsbHTDq9EKCKHk5WYVwZjpxxemaxrZAhm5+WXEceMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Extract_Month bis" = _t]),
ExtractMonth6= Table.AddColumn ( Source, "Extract_Month -6", let varMonths = List.Distinct ( Source[Extract_Month bis] ) in each if [Extract_Month bis] = varMonths{5} then [Extract_Month bis] else null )
in
ExtractMonth6
PBIBeginner2022
4 years agoHelper III
jennratten thanks for your answer,
But I would just add a new custom column in my table which have already lot of column .... I can't use this code I think.
- jennratten4 years agoSuper User
Hello again - the solution above creates a table that matches your post "I want this in Power Query". If you are wanting something different, can you please describe the expected results?
- PBIBeginner20224 years agoHelper III
I have table with lots of column like "Extract_ Month bis". I want added a new column called "Extract_month -6" with the same result that I send you above.
- jennratten4 years agoSuper User
Hello - the result you are requesting matches the outcome of the solution provided. I have shown them side-by-side below.