• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Power Query - Parameters type Date on SQL Source |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Power Query - Parameters type Date on SQL Source |Power Query|Excel Forum|My Online Training Hub

office scripts course

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryPower Query - Parameters type Dat…
sp_PrintTopic sp_TopicIcon
Power Query - Parameters type Date on SQL Source
Avatar
Cristina Lima

New Member
Members
Level 0
Forum Posts: 1
Member Since:
January 9, 2021
sp_UserOfflineSmall Offline
1
January 9, 2021 - 2:22 am
sp_Permalink sp_Print

Hi,

I'm trying to put a paremeters from date type on SQL Source but I have the following error:

DataSource.Error: Microsoft SQL: Incorrect syntax near 'lf'.
Details:
DataSourceKind=SQL
DataSourcePath=datacenter1.compulab.pt\server72,1472;Alfabares_WMS
Message=Incorrect syntax near 'lf'.
ErrorCode=-2146232060
Number=102
Class=15

_______________________________________________________

The code is:

let

ParamTable1 = Excel.CurrentWorkbook(){[Name="Rececao"]}[Content],
Param1 = "'" & Text.From(ParamTable1[Data]{0}) & "'",
Source = Sql.Database("datacenter1.compulab.pt\server72,1472", "Alfabares_WMS", [Query="#(lf)select sku, max (Validade) as ValidadeMax from (#(lf)select ent.docstatus as statusPHC,format(enc.DocDate, 'dd-MM-yyyy') as DataRececao,enc.ERPDocNum, e.Name as Fornecedor, linhaenc.SKU,sk.Name as SKUName,linhaenc.Qty as QTDENcomendada,loteentrada.Qty as QTDConfirmada,#(lf)loteentrada.NetWeight as PesoConfirmado,lote.Batch, DATEDIFF (day, enc.DocDate, lote.ValidityDate) as diasValidade, convert(varchar,lote.ValidityDate,23) as Validade#(lf), linhaentrada.changedate#(lf), lote.ChangeBy as Responsavel#(lf)from [Alfabares_WMS].[dbo].T_WMS_Doc enc#(lf) join [Alfabares_WMS].[dbo].T_WMS_DocDetail linhaenc on enc.DocID=linhaenc.DocID#(lf) left join [Alfabares_WMS].[dbo].T_WMS_DocDetail linhaentrada on linhaenc.DocDetailID=linhaentrada.RelatedLineID#(lf) left join [Alfabares_WMS].[dbo].T_WMS_DocDetailBatch loteentrada on linhaentrada.DocDetailID=loteentrada.DocDetailID#(lf) left join [Alfabares_WMS].[dbo].T_WMS_Batch lote on loteentrada.BatchID=lote.BatchID#(lf) join [Alfabares_WMS].[dbo].T_WMS_DocDefinition encdef on enc.DocDefID=encdef.DocDefID#(lf) join [Alfabares_WMS].[dbo].T_WMS_SKU sk on linhaenc.SKU=sk.SKU#(lf) join [Alfabares_WMS].[dbo].T_WMS_Entity e on enc.EntityID=e.EntityID#(lf) left join [Alfabares_WMS].[dbo].T_WMS_Doc ent on linhaentrada.DocId=ent.DocId#(lf)where enc.DocDefID in (24) and enc.ERPDocSeries like (2) and format(enc.DocDate, 'yyyy') >=2020 and
convert(varchar,enc.DocDate,23)< convert(varchar,"&Param1 & ",23) lf) ) as A#(lf)where QTDConfirmada>0#(lf)group by SKU"])
in
Source

___________________________________

 

The Param1 - has filled with 06/01/2021

 

Any one can help me.

 

Thanks.

 

Cristina 

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1844
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
January 9, 2021 - 1:47 pm
sp_Permalink sp_Print

I suggest removing #(lf) from the query, it's not necessary.
Best is to test the query text into sql server directly in the database, before using it in PQ

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Alan Sidman, John DiMatteo, Leigh Thomas
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
jaryszek: 183
Newest Members:
Trevor Pindling
Stevan Kanjo
Erin Sheldon
Nikita Bhatia
Sheilah Taylor
Clare Webber
David Jenssen
Dominic Brosnahan
Young You
Jennifer Owens
Forum Stats:
Groups: 3
Forums: 24
Topics: 6525
Posts: 28555

 

Member Stats:
Guest Posters: 49
Members: 32808
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.