Hi,
I recently had to use a variable in power query , I could not get it to accept the column name ,but haven't been able to find much information on how to use them. I had to declare the start date (sdate) as a variable to use with List.Select, but then had to also make the rest a variable also up to that point it had just been ? whatever not being a VAR is ?
Work book attached ; queries 'typed in ' and "VAR steps" .
Table.AddColumn( ddate , "new date " ,each
let Mdate = [Sdate] ,
change =
List.Distinct(
List.Select(
List.InsertRange(
List.Transform(
{ Number.From([Sdate]) .. Number.From([End Date]) },
(A)=> Date.StartOfMonth( Date.From(A) ) ),0,{ [Sdate]} ),
each Number.From(_) >= Number.From(Mdate) ))
in change)
I tried using ;
let Mdate = [Sdate] ,
Table.AddColumn( ddate , "new date " ,each
List.Distinct(
List.Select(
List.InsertRange(
List.Transform(
{ Number.From([Sdate]) .. Number.From([End Date]) },
(A)=> Date.StartOfMonth( Date.From(A) ) ),0,{ [Sdate]} ),
each Number.From(_) >= Number.From(Mdate) ))
)
but this didn't work, can someone help with information on why I had to use the variable in the first place and any general help
Richard
Bookmarks