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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MichaelShown
Frequent Visitor

How to use date parameters in power query

Hello,

 

I'd like to know if a date (e.g. YYYY-MM-DD) can be used as one of parameters in power query of Power BI desktop.

As shown below, when adding actual dates in query, the system shows correct results.

a.PNG

However, when using date parameters in the query, the system does not show any results.

b.PNG

 Does anyone know why date parameter is not working?

(FYI, data connectivity mode is 'DirectQuery'.)

 Any comments will be very appreciated.

 Thank you.

1 ACCEPTED SOLUTION

Hi @MichaelShown 

 

& is used to concatenate text strings. Your parameters S_DATE and E_DATE are both of date type, so one solution is to change both of them into Text data type. 

 

Another option is to use Date.ToText or Text.From function to convert the parameter values to text type in the code directly:

"... Start_Date Between '" & Date.ToText(S_DATE, [Format="yyyy-MM-dd"]) & "' AND '" & Date.ToText(E_DATE, [Format="yyyy-MM-dd"]) & "' AND ... "

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
MichaelShown
Frequent Visitor

I tried your suggestion but as shown below, I'm getting the error message : 

"Expression.Error: We cannot apply operator < to types Date and DateTime"

 

MichaelShown_0-1688465322518.png

 

Any comments will be appreciated.

 

Hi @MichaelShown 

 

& is used to concatenate text strings. Your parameters S_DATE and E_DATE are both of date type, so one solution is to change both of them into Text data type. 

 

Another option is to use Date.ToText or Text.From function to convert the parameter values to text type in the code directly:

"... Start_Date Between '" & Date.ToText(S_DATE, [Format="yyyy-MM-dd"]) & "' AND '" & Date.ToText(E_DATE, [Format="yyyy-MM-dd"]) & "' AND ... "

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

ppm1
Solution Sage
Solution Sage

Try this instead.

 

"... Start_Date Between '" & S_Date & "' AND '" & E_Date & "' AND ... "

 

Pat

 

Microsoft Employee

As a solution : When creating a new parameter, define the Type as Text and then use '"&S_Date&"'. This syntax works.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors