Forum Discussion
Powerquery Dynamic LOOKUP value
- 7 years ago
The previous step name is usually of the form #"Step Name". You have to use the octothorpe and quotes unless you renamed that step in the advanced editor. I'm guessing this is what you want:
= List.Single( Table.SelectRows( #"Fin YearMonthM", each [Date] = CurrentDate )[Fin MonthNo] )
The previous step name is usually of the form #"Step Name". You have to use the octothorpe and quotes unless you renamed that step in the advanced editor. I'm guessing this is what you want:
= List.Single(
Table.SelectRows(
#"Fin YearMonthM",
each [Date] = CurrentDate
)[Fin MonthNo]
)Thank you it worked perfectly.
The result is a single value that shows up.
I inserted a step after this and I would like to make a simple IF statement comparing this extracted value vs the Month from the CurrentDate
statement something like
if [Vlookup to Fin MonthNo] = Date.Month(CurrentDate) then "xx" else "xy"
Vlookup to Fin MonthNo is the value I calculated earlier using your code.
However I get an error The field 'Vlookup to Fin MonthNo' of the record wasn't found. I am assuming the problem is that the value we obtained "Vlookup to Fin MonthNo", M code is not recognizing it as a field. Is there any way to tell M to recognice as a field. Or maybe an alternative is to make a new column and fill this column with the result of the calcualtion from the previous code ....and then this would be a field and hence we can do a if statement relating to this newly calculated field ?