SPOTFIRE: Clean dat in the default Data Table - tibco

I am looking to clean data in one particular colum on my default data Table.
The column looks like this:
x
-----------
FR / NYC-PAR
FR - NYC-PAR
I want to change all the values of FR - NYC-PAR as FR / NYC-PAR without adding a new calculated column. Would this be possible by writing an expression? I also dont want to replace the data table.
Thanks in advance for your suggestions.

This will work for you:
Tools > Insert Transformations > Calculate and replace column
Then use this expression, where c1 is the name of the column:
RXReplace([C1],"[/]","-","") as [C1]

Related

Power Query Replace null values with values from another column

I am working with data imported from a pdf file. There is an extra column in the Power Query import (Data.Column7), containing data that belongs in the adjacent columns on either side (Data.Column6 and Data.Column8). Columns 6 and 8 have null values in the cells where the data was pushed into Column 7. I would like to replace the null values in Columns 6 and 8 with the correct data from Column 7, leaving all other values Columns 6 and 8 as is.
After looking at the post here:
Power Query / Power BI - replacing null values with value from another column
and watching this video:
https://www.youtube.com/watch?v=ikzeQgdKA0Q
I tried the following formula:
= Table.ReplaceValue(#"Expanded Data",null, each _[Data.Column7] ,Replacer.ReplaceText,{"Data.Column6","Data.Column8"})
(Note, "Expanded Data" is the last step before this Replace Value step.)
I am not getting any kind of syntax error, but the Replace Value step isn't doing anything at all. My null values in Columns 6 and 8 have not been replaced with the correct data from Column 7.
Any insight into how to achieve replacement would be greatly appreciated. Thank you.
(I should mention, I am a new Power Query user, so please be detailed and assume I know nothing!)
I'm sure there must be some way to do this with the ReplaceValue function, but I think it might be easier to do the following:
1: Create a new column with definition NewData6= if[Data.Column6]=null then [Data.Column7] else [Data.Column6]
2: Do the same thing for 8 : NewData8= if[Data.Column8]=null then [Data.Column7] else [Data.Column8]
3: Delete Data.Column6/7/8
4: Rename the newly made columns if neccesary.
You can do these steps either in the advanced editor, or just use the create custom column button in the add column tab.
If the columns are of the text data type, then it might have empty strings instead of actual nulls.
Try replacing null with "" in your formula.

Why the field has been cut into two parts in Hive?

Here is the code:
-- create table novaya.unnormal as
select query from default.daily_session_mobile
where dt = '20161020'
and page in ('/click_search_deal', '/click_search_product')
and query like '%memberID=33930938%'
and query like '%스텐드지퍼팩%'
The result only has one record and it is right
The value in the field of "query" is
searchCount=52&rank=39&logType=click&currentView=/search_list&searchId=4c3ecee1354943e999e0c1566243bf87&logCategory=event&itemID=22780015&itemProductID=4&q=스텐드지퍼팩&memberID=33930938&productID=4993730&eventReferrer=/click_search_list&request_time=1476889555129&tz=+0900&appVersion=4.3.8&wl_mo=LG-F400L&wl_ma=LGE&wl_sn=Android&wl_v=4.4.2&wl_r=1440x2392&wl_l=ko&wl_c=KR
and there is no space in the value. We focus on the "q=스텐드지퍼팩&" in it.
It seems good.
But when I use create table novaya.unnormal as select ...
the table novaya.unnormal's query have been cut.
The new "query" only has a part of the whole query which is
"searchCount=52&rank=39&logType=click&currentView=/search_list&searchId=4c3ecee1354943e999e0c1566243bf87&logCategory=event&itemID=22780015&itemProductID=4&q="
half of it is missing.
What is wrong with this?
When you create a table using create table novaya.unnormal as statement, without specifying any input/output format and delimiters, all defaults will be chosen which probably causes the 스 character to act as a separator.
I suggest looking at the properties of the source table (describe formatted default.daily_session_mobile), and creating the new table with similar input/output format and delimiters. (setting them between novaya.unnormal and as)

How to update a column with concatenate of two other column in a same table

I have a table with 3 columns a, b and c. I want to know how to update the value of third column with concatenate of two other columns in each row.
before update
A B c
-------------
1 4
2 5
3 6
after update
A B c
-------------
1 4 1_4
2 5 2_5
3 6 3_6
How can I do this in oracle?
Use the concatentation operator ||:
update mytable set
c = a || '_' || b
Or better, to avoid having to rerun this whenever rows are inserted or updated:
create view myview as
select *, a || '_' || b as c
from mytable
Firstly, you are violating the rules of normalization. You must re-think about the design. If you have the values in the table columns, then to get a computed value, all you need is a select statement to fetch the result the way you want. Storing computed values is generally a bad idea and considered a bad design.
Anyway,
Since you are on 11g, If you really want to have a computed column, then I would suggest a VIRTUAL COLUMN than manually updating the column. There is a lot of overhead involved with an UPDATE statement. Using a virtual column would reduce a lot of the overhead. Also, you would completely get rid of the manual effort and those lines of code to do the update. Oracle does the job for you.
Of course, you will use the same condition of concatenation in the virtual column clause.
Something like,
Column_c varchar2(50) GENERATED ALWAYS AS (column_a||'_'||column_b) VIRTUAL
Note : There are certain restrictions on its use. So please refer the documentation before implementing it. However, for the simple use case provided by OP, a virtual column is a straight fit.
Update I did a small test. There were few observations. Please read this question for a better understanding about how to implement my suggestion.

How to perform an add functionality in sql loader file

I have a fixed length data file a.dat with below data in it
1234544550002200011000330006600000
my focus is on specific positions
POSITION(1:4)
POSITION(5:8)
and I want to add values in these 2 positions and insert it in a field named Qty in XYZ_Table.
I am trying to the following in my CTL file. But it fails, and I don't know how to pursue it further.
LOAD DATA
INFILE '$SOME_DATA/a.dat'
APPEND
PRESERVE BLANKS
INTO TABLE XYZ_Table
(QTY POSITION(1:4)+POSITION(5:8) "to_number(:QTY)")
I need to achieve this addition functionality in SQL Loader only.
If the above methodology is not possible, it would be great if you can help me with a different approach.
P.S: What I am trying to achieve is just one part of the bigger CTL file.
You need to identify the positions you want to add together but not load into their own columns as "BOUNDFILLER", which means don't load them but remember them for use in an expression later. Then use like this:
LOAD DATA
infile test.dat
append
preserve blanks
INTO TABLE X_test
TRAILING NULLCOLS
(val_1 BOUNDFILLER position(1:4)
,val_2 BOUNDFILLER position(5:8)
,qty ":val_1 + :val_2"
)

How is the best way to generate a calendar table in PowerCenter?

I must generate a table of calendar dates from dateIni to dateEnd in Powercenter Designer.
dateIni is is fixed, for example '2013-01-01'
dateEnd is sysdate + 'n' months
I'm trying to generate from a java tranformation, that can generate several dynamic rows but needs an input row and I do not have any input... it there any other better approach using seq generator???
As an example table content result must be
date
=======
'2013-01-01'
'2013-01-02'
'2013-01-03'
...
...
'2016-03-10'
You can pass a single input row from any source into the Java transformation and then generate rows with consecutive dates in a loop.
You can create a simple table with two columns - dateIni and dateEnd. It will contain a single row that will both kickstart the Java code and provide configuration for the mapping.
When working with an Oracle database you can also use the following query in your source qualifier:
SELECT level
FROM dual
CONNECT BY
level <= 1000 --(or any other number)
This will generate 1000 rows.
With an Expression-transformation you can change this into dates:
ADD_TO_DATE(to_date('20190101','yyyymmdd'), 'DAY',Level)

Resources