I'm trying to execute a stored procedure in Power BI, where a user can input a data value in the parameter.
let
Source = Sql.Database("nj1tstsql12", "GI_MASTER", [Query="exec
dal_ANALYTICS_TIME_SERIES_SUMMARY_BY_SECTOR " &AsOfDate])
in
Source
I keep on receiving this error:
Expression.Error: We cannot apply operator & to types Text and DateTime.
Details:
Operator=&
Left=exec dal_ANALYTICS_TIME_SERIES_SUMMARY_BY_SECTOR
Right=12/10/2018 12:00:00 AM
Thanks!
As the others said on comments, you need to change the data into Text format. You made a syntax error when you did, that's why you got another error. Please try below:
let
Source = Sql.Database("nj1tstsql12",
"GI_MASTER",
[Query="exec dal_ANALYTICS_TIME_SERIES_SUMMARY_BY_SECTOR '" & Date.ToText(AsOfDate) & "'"])
in
Source
Related
I am trying to populate TIMESTAMP_TZ column in Snowflake using the Informatica IICS from the Taskflow. In the taskflow I am using function fn:current-dateTime() which I am trying then in the mapping to convert to TIMESTAMP_TZ using the to_date() function but I am getting error
MAPPING> TE_7002 [2023-01-17 11:07:50.987] Transformation stopped due to a fatal error in the mapping. The expression [To_Date($$inp_load_dttm)] contains the following errors [<<PM Parse Error>> [$$inp_load_dttm)]: Invalid date value string: >>>2023-01-17T16:06:58.019Z<<<.
... To_Date(>>>>$$inp_load_dttm<<<<)].
MANAGER> PETL_24005 [2023-01-17 11:07:50.988] Starting post-session tasks. : (Tue Jan 17 11:07:50 2023)
fn:current-dateTime() returns date (ref 1). to_date expects a string (ref 2). Here in this case you should not try to conver a date to date - it should simply work. If what you need is just the date, without the time, try using fn:current-date().
I'm developing a data fusion pipeline. It contains a wrangler node where I'm trying to create a new field that will contain the system date in timestamp format (yyyy-MM-dd'T'HH-mm-ss).
I've tried using the sentence:
set-column :sysdate (${logicalStartTime(yyyy-MM-dd'T'HH-mm-ss)})
But I receive the error:
Caused by: io.cdap.wrangler.api.DirectiveParseException: Error encountered while parsing 'set-column' : Error encountered while compiling '( 2022 -12-01T16-29-32 ) ' at line '1' and column '14'. Make sure a valid jexl transformation is provided.
Which would be the correct sentence?
I've tried:
set-column :sysdate (${logicalStartTime(yyyy-MM-ddHH-mm-ss)})
Which will result in something like "1877", as it substracts the numbers, and also tried:
set-column :sysdate (${logicalStartTime(yyyyMMddHHmmss)})
but the format isn't correct and can only be written if the field is a String.
You have the correct method, just incorrect syntax. The syntax you are looking for is set-column :sysdate ${logicalStartTime(yyyy-MM-dd'T'HH-mm-ss)}, you have to remove (). Then you can convert the string in datetime pattern in this format parse-as-datetime :sysdate "yyyy-MM-dd'T'HH-mm-ss".
I want to run a query in Advanced Editor, only if the current date is NOT one of the following - 1, 5, 10, 15, 20, 25. Otherwise I dont want the query to run.
I have written the below but I am not getting anywhere very fast:
let
Output = if Date.Day (DateTime.LocalNow()) in (1,5,10,15,20,25) then null else
let
Source = PBILifts
in
#"PBILifts"
What am I doing wrong?
Cheers for all help
Edit: So based on suggestion by #Aleksei I tried below but it doesnt work:
let
output= if List.Contains({1,5,10,15,20,25}, Date.Day(DateTime.LocalNow())) then #table({},{}) else
Source = PBILifts
in
#"PBILifts"
I get the below error:
An error occurred in the ‘’ query. Expression.Error: The name 'Source' wasn't recognized. Make sure it's spelled correctly
Any further help please?
It's PQ, not SQL, so in (1,5,...) syntax is incorrect. Try something like this (assuming, your query's output is table):
= if List.Contains({1,5,10,15,20,25}, Date.Day(DateTime.LocalNow())) then #table({},{}) else YourQuery
or:
let
output = if List.Contains({1,5,10,15,20,25}, Date.Day(DateTime.LocalNow())) then #table({},{}) else PBILifts
in
output
I'm brand new to using PBI but as far as I can tell, I should be able to substitute a parameter as part of a Direct Query in place of a hard-coded variable...ie
let
Source = Sql.Database("NAMEOFDB", "CMUtility", [Query="sp_get_residentsinfo "& home_name]),.....
instead of
let
Source = Sql.Database("NAMEOFDB", "CMUtility", [Query="sp_get_residentsinfo 'NAME OF HOME'"]),...
However, the parameter-included version just says
DataSource.Error: Microsoft SQL: Incorrect syntax near 'House'.
Details:
DataSourceKind=SQL
DataSourcePath=NAMEOFDB;CMUtility
Message=Incorrect syntax near 'House'.
Number=102
Class=15
"House" is the currently - assigned last word of the home_name variable. What have I done wrong?
PS - I have surmised that I shouldn't need the extra & at the end of the parameter, as I'm not adding anything else to the query, but even with both &s it still doesn't work.
The type of your parameters is text. In SQL, text literals must be quoted, i.e. sp_get_residentsinfo 'NAME OF HOME', but the statement build by you is sp_get_residentsinfo NAME OF HOME.
You should use Text.Replace to escape single quotes in the parameter's value and append a quote before and after it.
So I've looked through documentation and previous answers on here, but can't seem to figure this out.
I have a STRING that represents a date. A normal output looks as such:
2018-09-19 17:47:12
If I do this, I get it to return in this format 2018-09-19 17:47:12.000:
SELECT
date_parse(click_time,'%Y-%m-%d %H:%i:%s') click_time
FROM
table.abc
But that's not the output I need. I was just trying to show that I'm close, but clearly missing something. When I change click_time to date_parse(click_time,'%Y-%m-%d'), it sends back INVALID_FUNCTION_ARGUMENT: Invalid format: "2018-09-19 17:47:12" is malformed at " 17:47:12"
So there's clearly something I'm not doing correctly to get it to simply return 2018-09-19.
date_parse converts a string to a timestamp. As per the documentation, date_parse does this:
date_parse(string, format) → timestamp
It parses a string to a timestamp using the supplied format.
So for your use case, you need to do the following:
cast(date_parse(click_time,'%Y-%m-%d %H:%i:%s')) as date )
For your further reference, you can go to the below link for prestodb online documentation https://prestodb.github.io/docs/current/functions/datetime.html