"0" to date- ssis, derived column - ssis

I have a flat file which coming as str (fixed delimeted) and consists in data like this: "20130505" or "0"(only one digit). My destination has to be a date. i make substring by derived column and transform the date to like this :
(2013-04-05):
ISNULL(FIELD_1519_Out) ? (DT_DBDATE)(SUBSTRING(FIELD_1519,1,4) + "-" +
SUBSTRING(FIELD_1519,5,2) + "-" + SUBSTRING(FIELD_1519,7,2)) : (DT_DBDATE)
(SUBSTRING(FIELD_1519_Out,1,4) + "-" + SUBSTRING(FIELD_1519_Out,5,2) + "-" +
SUBSTRING(FIELD_1519_Out,7,2)).
My question is how can i transform "0" to the requested length in order to convert it to date? Since there is the only one digit - "0"' i cannot continue with same logical substring.
Thanks

See the example below, this may help you. My source data is as shown below.The column [yourDate] is VARCHAR(8)
I developed an SSIS package as below. the output of data viewer is what the devived column gives.
Derived column content.
(DT_STR,8,1252)RIGHT(("0000000" + yourDate),8)
You use such a derived column in your DFT.I am still not sure, whether this is what you are looking for,

Related

Google Sheet Query and ImportHTML Function show numerical values as text

I'm importing some data using the formula below but the numerical values appear as =1599 (for example) and are being treated as text (ie cannot use them in a formula).Does anyone know how to substitute the "=" to "" in the table? The numerical values are in column H.
={QUERY(IMPORTHTML("https://1234567.website.com","table",0), "where Col1 is not null",1)}
I tried wrapping in:
SUBSTITUTE( ... ,"=","")
ARRAYFORMULA(SUBSTITUTE( ... , "=","")
TO_PURE_NUMBER(
Nothing works. Is there a way to apply one of these solutions only to the columns with numerical values?
Try iferror() and regexextract(), like this:
=arrayformula(
lambda(
data,
iferror(value(regexextract(data, "[-.\d%]+")), data)
)(
importhtml("https://1234567.website.com", "table", 0)
)
)

Error when trying to split a column using powerquery in Azure Data Factory -UserQuery : Expression.Error: An error occurred invoking 'Table.AddColumn'

I get the following error when trying to split a column by space delimiter on PowerQuery in Data Factory :
UserQuery : Expression.Error: An error occurred invoking 'Table.AddColumn': We can't get the expression for the specified value.
What is causing this and how would I go about resolving it?
Many thanks
This is the error
The PowerQuery itself is :
let
Source = dedupedetipscsv,
#"Split Column by Delimiter" = Table.SplitColumn(Source, "Candidate", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Candidate.1", "Candidate.2"}),
#"Split Column by Delimiter1" = Table.SplitColumn(Table.TransformColumnTypes(#"Split Column by Delimiter", {{"ApprovedDate", type text}}, "en-GB"), "ApprovedDate", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"ApprovedDate.1", "ApprovedDate.2"})
in
#"Split Column by Delimiter1"
Note: Power Query will split the column into as many columns as needed. The name of the new columns will contain the same name as the
original column. A suffix that includes a dot and a number that
represents the split sections of the original column will be appended
to the name of the new columns.
In the Table.AddColumn step might refer to variable which is a List. You need to refer to #"Renamed Columns" which is the last step that results in a table.
Split columns by delimiter into columns | Here
Make sure : An alternate for split by length and by position is listed below | M script workarounds
Table.AddColumn(Source, "First characters", each Text.Start([Email], 7), type text)
Table.AddColumn(#"Inserted first characters", "Text range", each Text.Middle([Email], 4, 9), type text)

how to read data separated by ' ' but that has decimal numbers with comma

I need to read and modify a .txt file with thousands of lines. This file represents the reading of a digital signal. Each line has the following format:
8867.16787 : 1
There are two numbers separated by " space : space ":
The first number is a decimal number separated by '.'
The second number is a integer number that can be 0 or 1.
The meaning is: The first number is a kind of time measure and the second is the bit read.
Considering a matrix of four lines as an example:
1532.25071 : 0
1532.26311 : 0
1532.27511 : 0
1532.28751 : 1
I would like a matrix of two columns, where the first column would be:
1532.25071
1532.26311
1532.27511
1532.28751
and the second:
0
0
0
1
I tried the following code:
fid = fopen('fileName');
A = textscan(fid,'%s %c %c');
fclose(fid);
But, when I do this I have a Matrix of dimension 1x3.
Does someone know how to do it ?
One solution is to just use other format specifiers for textscan, then format the output from a cell array into a matrix of values. Try this:
fid = fopen('fileName');
A = textscan(fid, '%f : %f'); % Read both as double values
fclose(fid);
A = [A{:}]; % Horizontally concatenate into an N-by-2 double matrix
I did the following and worked fine:
fileX = 'fileName';
delimitador = ' : ';
A = importdata(fileX );

How do I build an SSRS expression for the NoRowsMessage that shows report parameter values?

How do I build an SSRS expression for the NoRowsMessage that shows report parameter values?
something like:
="No locations were found for this street name : " + #StreetName
I have also tried this:
="No locations were found for this street name : " + Parameters!StreetName.Value
The second attempt worked fine:
="No locations were found for this street name : " + Parameters!StreetName.Value
I can add in carriage returns also as per this article which suggests the use of vbcrlf
=vbcrlf + "No locations were found for this street name : " + Parameters!StreetName.Value

SQL - How do I replace/modify strings in multiple rows?

I have a lot of rows in database where column "info" is ie. "Size, inch: 12x13<br>Material: paper<br>Amount: 100pcs". Now I need to find/select all rows that has this string part "Size, inch:" and replace/fix those rows' colums to ie. "Size: 12x13 inch<br> Material: paper<br>Amount: 100pcs ".
How in the world I write a sql statement for this? Do I need some magic regexp for sql? How do I replace and modify parts of a string in multiple rows?
EDIT: The numbers can be anything (ie. 12x13 or 44x55 or 77x88x99 etc.) So there would have to be some kind of wildcard for the numbers, perhaps?
I need to change "Size, inch: 'anynumbershere' 'anythingafter the numbers'" to "Size: 'anynumbershere' inch 'anythingafter'".
update mytable set info=REPLACE ( info , 'Size, inch: 12x13 ', 'Size: 12x13 inch' )
where info like '%inch:12X13%'
Perhaps this will work:
update table t
info = replace(replace(info, 'Size inch:', 'Size:'), '<br>Material', ' inch<br>Material')
where info like 'Size inch:%<br>Material%';
Note: this assumes that 'Size inch' and '<br>Material' only appear once in each string.