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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
haider378
Regular Visitor

Date parameter SAP Hana

Hi,

 

I have query from SAP hana that contain start date and end date, I am try to manage this start and end date with Power Query parameters. below is my query

 

--Khi Branch Receipts by Haider Ali
--Version 1.0
SELECT
T1."TransId",
TO_NVARCHAR(T1."DocDate",'dd-Mon-yy') AS "DDate",
--T1."DocDate",
T1."CounterRef",
T1."CardName",
T1."CardCode",
T1."DocTotal",
T1."Canceled",
T1."CashSum",
T1."TrsfrSum",
T1."Series",
T1."DocTime"
FROM LIVE_SRW."ORCT"
T1 WHERE T1."DocDate" >= '2021-07-01'
AND T1."DocDate" <='2021-08-31'
AND T1."CardCode" LIKE '%KHI%'
ORDER BY T1."DocDate",T1."TransId"

 

I have tried date parameter and text parameter too 

haider378_0-1631690984208.png

and using advance editor I have replaced Start date with parameter name as below

= SapHana.Database("192.168.1.8:30015", [Query="--Khi Branch Receipts by Haider Ali#(lf)--Version 1.0#(lf)SELECT #(lf)T1.""TransId"",#(lf)TO_NVARCHAR(T1.""DocDate"",'dd-Mon-yy') AS ""DDate"",#(lf)--T1.""DocDate"", #(lf)T1.""CounterRef"",#(lf)T1.""CardName"",#(lf)T1.""CardCode"", #(lf)T1.""DocTotal"",#(lf)T1.""Canceled"",#(lf)T1.""CashSum"",#(lf)T1.""TrsfrSum"", #(lf)T1.""Series"", #(lf)T1.""DocTime""#(lf) FROM LIVE_SRW.""ORCT""#(lf) T1 WHERE T1.""DocDate"" >= 'StartDate'#(lf) AND T1.""DocDate"" <='2021-08-31'#(lf) AND T1.""CardCode"" LIKE '%KHI%' #(lf)ORDER BY T1.""DocDate"",T1.""TransId""", Implementation="2.0"])

 

but after this following error appear

haider378_1-1631691128668.png

I just want to manage start and end date of query using parameter

 

Thanks

Haider Ali

3 REPLIES 3
Anonymous
Not applicable

@haider378 
You cannot use the parameter inside the sql query. The parameter is created to be used in power bi with M query. For example, I can replace a date value with the parameter in the advanced editor. 

Vpazhenmsft_3-1631862429943.png

 

Vpazhenmsft_2-1631862405220.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

Thanks for your response,

What I understand it is not possible to change Query using parameter

I use DateTime parameters in SQL queries in Power Query for data from the Data Warehouse.
I don't know how to use M parameters in SQL queries of SAP Hana yet, but it's possible.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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