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

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

Reply
rdnguyen
Helper V
Helper V

Error "We cannot convert a value of type Function to type Logical"

Hi All,

I have this SQL query that I tried to convert to Power Query

SELECT  labID,
(Select COUNT(*) from tblRouting

          where JobNo = tblLabor.jobno and operno <= tblLabor.operno) as OpCount,
(Select SUM(fuprodtime * foperqty  + fsetuptime + fmovetime) from tblRouting

          where JobNo = tblLabor.jobno and operno <= tblLabor.operno) as CompHrs
FROM tblLabor

 

converted to power query as following:

let
  Source = tblLabor,
  #"Choose columns" = Table.SelectColumns(Source, {"jobno""operno"}),
  #"Removed duplicates" = Table.Distinct(#"Choose columns", {"jobno""operno"}),
  #"Merged queries" = Table.NestedJoin(#"Removed duplicates", {"jobno"}, #"tblRouting", {"jobno"}, "jr", JoinKind.LeftOuter),
  #"Added custom" = Table.AddColumn(#"Merged queries", "Custom"each Table.SelectRows(Table.Buffer([jr]),each (jr)=> jr[operno] <= [operno] )),
  #"Expanded Custom" = Table.ExpandTableColumn(#"Added custom", "Custom", {"operno""Hours"}, {"operno.1""Hours"})
in
  #"Expanded Custom"
 
So what I did is perform Left outer join of the two table matching jobno then add custom Column using SelectRows on the nested table to filter down those operno not matching criteria. 
 
Kindly help me on this.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

"Added custom" = Table.AddColumn(#"Merged queries", "Custom", each Table.SelectRows(Table.Buffer([jr]),each (jr)=> jr[operno] <= [operno] )),

 

 

"Added custom" = Table.AddColumn(#"Merged queries", "Custom", each Table.SelectRows(Table.Buffer([jr]),(jr)=> jr[operno] <= [operno] )),

try to cut each on front of (jr)=>

View solution in original post

2 REPLIES 2
rdnguyen
Helper V
Helper V

Thanks Rocco,

that worked.

Anonymous
Not applicable

"Added custom" = Table.AddColumn(#"Merged queries", "Custom", each Table.SelectRows(Table.Buffer([jr]),each (jr)=> jr[operno] <= [operno] )),

 

 

"Added custom" = Table.AddColumn(#"Merged queries", "Custom", each Table.SelectRows(Table.Buffer([jr]),(jr)=> jr[operno] <= [operno] )),

try to cut each on front of (jr)=>

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors