Trying to use the WHERE statement in Power Query

shophoney

Active Member
Joined
Jun 16, 2014
Messages
281
[FONT=&quot]Hi I’m looking at trying to query fold. I have read that this will speed things up for us.[/FONT]
[FONT=&quot]The Qry below is from EXCEL and filters only selected dates. But when I try to convert the SQL statement to M in excel it doesn’t like the “WHERE” function. I am connecting a few tables from our SQL SERVER to run this query.[/FONT]
[FONT=&quot]SELECT dbo_tblSale.sale_link, dbo_tblSale.loc_code AS [LOC#], dbo_tblSale.Date AS [TRANS DATE], dbo_tblSale.Time, dbo_tblSale.trans_no AS [TRANS#], dbo_tblSale.customer_code AS [CUST#], dbo_tblSaleCommission.salesperson, dbo_tblSaleItem.sku_no AS [SKU#], dbo_tblSaleItem.description, Min(dbo_tblSaleDiscount.disc_code) AS [DISCOUNT CODE], dbo_tblSaleItem.qty AS [UNITS SOLD], dbo_tblSaleItem.ext_cost AS COST, [unit_ext_price]-[unit_ext_best_price] AS DISCOUNT, dbo_tblSaleItem.unit_ext_price, dbo_tblSaleItem.unit_ext_best_price AS [NET RETAIL], dbo_tblSaleItem.line_no, dbo_tblSale.trans_type, dbo_tblSale.void_code, dbo_tblSale.suspended, dbo_tblSaleItem.affect_inv, dbo_tblSaleItem.affect_total, dbo_tblSale.note AS [SALE NOTE], dbo_tblSaleItem.note AS [SALE ITEM NOTE]
FROM dbo_tblSaleDiscount RIGHT JOIN (dbo_tblSale INNER JOIN (dbo_tblSaleItem INNER JOIN dbo_tblSaleCommission ON (dbo_tblSaleItem.line_no = dbo_tblSaleCommission.line_no) AND (dbo_tblSaleItem.sale_link = dbo_tblSaleCommission.sale_link)) ON dbo_tblSale.sale_link = dbo_tblSaleItem.sale_link) ON (dbo_tblSaleDiscount.line_no = dbo_tblSaleItem.line_no) AND (dbo_tblSaleDiscount.sale_link = dbo_tblSaleItem.sale_link)
GROUP BY dbo_tblSale.sale_link, dbo_tblSale.loc_code, dbo_tblSale.Date, dbo_tblSale.Time, dbo_tblSale.trans_no, dbo_tblSale.customer_code, dbo_tblSaleCommission.salesperson, dbo_tblSaleItem.sku_no, dbo_tblSaleItem.description, dbo_tblSaleItem.qty, dbo_tblSaleItem.ext_cost, [unit_ext_price]-[unit_ext_best_price], dbo_tblSaleItem.unit_ext_price, dbo_tblSaleItem.unit_ext_best_price, dbo_tblSaleItem.line_no, dbo_tblSale.trans_type, dbo_tblSale.void_code, dbo_tblSale.suspended, dbo_tblSaleItem.affect_inv, dbo_tblSaleItem.affect_total, dbo_tblSale.note, dbo_tblSaleItem.note
HAVING (((dbo_tblSale.Date)>#1/31/2016#));[/FONT]
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top