cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RamRock
New Member

List.Max on Table.Select with Field Filter

I've got a Calendar query and a "Campaign" query and I'm trying to bring in the Campaign Start Date into my Calendar query. I'm trying to add a custom column:

 

 

Table.AddColumn(#"Changed Date column to Date Type","Campaign Start",each List.Max(Table.SelectRows(#"Campaign Dates", each [Starting_Date] <= [Date])[Starting_Date]))

 

 

Where [Date] is the date in my Calendar query, but I get the error of:

 

Expression.Error: The field 'Date' of the record wasn't found.

 

For example, my Calendar might have:

  • 01/01/2021
  • 01/02/2021
  • 01/03/2021
  • 01/04/2021
  • 01/05/2021

 

But my Campaigns have start dates like:

 

  • 01/01/2021
  • 01/05/2021

 

I'm essentially trying to mimic the Excel VLOOKUP(false) function in my Calendar query, where I retrieve results like:

 

DateCampaign Start
01/01/202101/01/2021
01/02/202101/01/2021
01/03/202101/01/2021
01/04/202101/01/2021
01/05/202101/05/2021

 

1 ACCEPTED SOLUTION
watkinnc
Super User
Super User

I would use the Merge GUI function (Join) to Join your calendar table to your campaign start table, and then fill down the nulls, like:

 

Table.Join(Calendar, {"Date"}, #"Campaign Start", {"Starting_Date"}, JoinKind.LeftOuter)

 

Now you can just use the FillDown button in the GUI to replace the nulls in the Campaign Start column.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@RamRock 
You cannot refer to the column in other tables in power query. You need do some transformation(merge,append,etc) to combine the date column into the Campaign query.

 

 

Paul Zheng _ Community Support Team

watkinnc
Super User
Super User

I would use the Merge GUI function (Join) to Join your calendar table to your campaign start table, and then fill down the nulls, like:

 

Table.Join(Calendar, {"Date"}, #"Campaign Start", {"Starting_Date"}, JoinKind.LeftOuter)

 

Now you can just use the FillDown button in the GUI to replace the nulls in the Campaign Start column.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors