Forum Discussion
Power Query - get column name
I don't quite follow. You need to specify "Job Name" once so the function knows what column you want to read text lengths from. There's no other place in what I suggested that has "Job Name" hard coded and the output is what you specified.
Maybe if I rewrite it a bit more like your code it will be slightly clearer?
(R as record, MyColumn as text) as text => //R = row 1, MyColumn = "Job Name"
let
Text = Record.Field(R, MyColumn), //Returns R[Job Name] = "Controller"
Source = Text.Length(Text), //Returns length("Controller") = 10
NewSource = Number.ToText(Source), //Returns "10"
FinalText = Text.Combine({MyColumn, NewSource}, " ") // "Job Name" & " " & "10"
in
FinalText // "Job Name 10"Sorry for the late reply.
In this function, I have two parameters: R & MyColumn. MyColumn works as a drop-down so I can pick a column from the drop-down list, but R is a parameter that I have to hand-write. See below:
- AlexisOlson3 years agoSuper User
Unfortunately, I can't think of any way to make this work using the Invoke Custom Function GUI and zero manual typing but typing fn_Len(_, "Job Name") in the Custom Column GUI isn't that bad (use Query1 instead of fn_Len if that's what your function is named).