Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vwormley
New Member

Power Query find date within 30 days

Hello all!

 

I have two tables in Power Query. One is for project completions and the other is a listing of repair work at the site. The project table shown here is only the first 4 projects out of 30. None of them have had all projects completed as you can see in the example. Here is the outcome I am looking for:

I want to see if there are any projects completed within 30 days of the Repair Visit and return the Project Name.
I also want the Within 30 days to indicate yes or no if a project is found.

I am super new to Power Query so any help would be great.

 

vwormley_0-1671657434043.png

 

 

2 REPLIES 2
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1671676372376.png

let
    Left = Excel.CurrentWorkbook(){[Name="Left"]}[Content],
    Right = Excel.CurrentWorkbook(){[Name="Right"]}[Content],
    Custom1 = let Unpivot_Left=Table.Buffer(Table.UnpivotOtherColumns(Left,{"Site Number"},"Proj","Date")) in #table(Table.ColumnNames(Right)&{"With 30 days?","Project Number"},Table.ToList(Right,each let a=List.Distinct(Table.SelectRows(Unpivot_Left,(x)=>x[Site Number]=_{0} and x[Date]>=_{1} and x[Date]<=Date.AddDays(_{1},30))[Proj]),b=if List.Count(a)>0 then {"Yes",Text.Combine(a,"/")} else {"No",null} in _&b))
in
    Custom1

 

Thank you for the assistance.  I have some questions.  Why does the repair table duplicate the site number and how do I get it to see if the repair date is within 30 days after the project instead of before it? Also when I change the repair dates this is what happens:

 

vwormley_1-1671744930999.png

vwormley_2-1671744981757.png

 

 

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.