Share via

Excel 2010 Power query: Change a parameter in SQL query using List values or Value in Cell of sheet1.

Anonymous
2014-08-06T07:37:52+00:00

Sir,

I am using Microsoft Excel 2010 with Powerquery add in (June 2014 released version). I am extracting the data into Excel sheet using SQL query ( OLE-DB Query). I have been successful in getting the results.

Every time, i need to change a parameter in Source query to obtain the required results. Query is shown below.

Select  distinct Workorder.location as "Equipment",

  workorder.wonum as "Work Order",

  workorder.actstart,

  Workorder.description as "WO Description",

  convert (varchar(20),Workorder.actstart,101) as "Start Date",

  Workorder.worktype as "Work Type",

  workorder.actlabhrs AS [Man Hours],

  workorder.actlabcost AS [Man Power Cost],

  Workorder.actmatcost as "Material Cost",

  Failureremark.description as "Short History"

from workorder left join locations on workorder.location = locations.location

  left join failureremark on workorder.wonum = failureremark.wonum

  where workorder.siteid = 'adrd'

  AND workorder.location = 'U5105LJ'

  AND workorder.worktype in ('pd','cm','md','pm')

  AND workorder.actstart >='01/01/1999 00:00:00'

  And workorder.actstart <= '04/30/2009 23:59:59'

  AND workorder.woclass = 'workorder'

order by workorder.actstart desc;

I would like to define a parameter for "Workorder.location" (present inside where clause) in Sheet1 of the same excel workbook (Can be single value or List values") so that the parameter in the query is changed automatically and runs to give the result.

Plealse assume server name: "00.00.000.000" and database name "qwerty".

I am basic user of Microsoft Power query. I am soliciting to have one of the following solutions.

  1. I am requesting to have solutions eith a "Function inside Power query", so that it can be invoked as required.
  2. VBA code
  3. Any other.

regards

P. Bangaru Rayudu

Reliability Cost Engineer

Abu Dhabi; UAE.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2014-08-06T19:19:30+00:00

    Hi Bangaru,

    Since you are using Powerquery add-in for Excel, your question would best be addressed in the Excel IT Pro forum. Refer to the following link to post your query.

    http://social.technet.microsoft.com/Forums/office/en-US/home?forum=excel

    If you have any other questions related to Office products, you can always reply and I’ll be happy to assist you.

    Thank you.

    0 comments No comments