Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
RichJ
Contributor III
Contributor III

set up a global rule to replace '' with ' '

Hi Sir,

I have a large number of tables with some column data type "STRING(1)", where we need to ensure if the value is '' (empty space) then re-set it as ' ' (one space).

It can be done by individual table transformation; but it world be idea to setup a global rule to achieve it. I tried numerous cases for global rules  like below, but none worked out -

case
   when $AR_M_SOURCE_DATATYPE_NAME = 'STRING' and $AR_M_SOURCE_DATATYPE_LENGTH = 1                   and $AR_M_SOURCE_COLUMN_NAME =''
   THEN $AR_M_SOURCE_COLUMN_NAME = ' '
   ELSE $AR_M_SOURCE_COLUMN_NAME
END

Appreciate the help,

Richard

Labels (3)
1 Solution

Accepted Solutions
Heinvandenheuvel
Specialist III
Specialist III

@RichJ <but there is no "$AR_M_SOURCE_COLUMN_DATA" available in global rule configuration page. >

I verified just now under 2023.5.0152.

You have to select "Replace column value" along the way otherwise the "data" tab will not show.

Heinvandenheuvel_0-1710877778642.png

 

View solution in original post

6 Replies
john_wang
Support
Support

Hello @RichJ ,

Thanks for reaching out to Qlik Community!

Not sure what's the source/target DBs types and the exact datatype in the table, so let's focus on the Global Transformation in Qlik Replicate now. Below is a sample:

1. New a Global Transformation rule "Replace column value"

2. Define the Transformation scope to STRING(1) by using

  Data type is         : STRING

  Scope Expression: $AR_M_SOURCE_DATATYPE_LENGTH == 1

    If the source column length is not 1 then the '' will NOT be replaced by ' '. Certainly you may add additional constraints eg schema name/table name/column name pattern etc.

john_wang_0-1710642892615.png

3. Using Null Check function ifnull(), the expression is:

  ifnull($AR_M_SOURCE_COLUMN_DATA,' ')

john_wang_1-1710643061398.png

Hope this helps.

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!
Heinvandenheuvel
Specialist III
Specialist III

Just a brainfart it seems, or maybe not the most recent version.

@RichJ  wrote - and $AR_M_SOURCE_COLUMN_NAME =''

But you need to set and get the columns DATA, not it's name.

Use: $AR_M_SOURCE_COLUMN_DATA

Note, this variable is NOT available/documented in early Replicate 'V7' versions but it is in 2023.11

Going in though the GUI you start with: Transformation Type - Column - Replace column value

Hein.

 

RichJ
Contributor III
Contributor III
Author

Hi John,

Thanks for help!  The source db is SQL Server, the target is Snowflake.  

If we have more than one global rules,  what is the order they got executed?

If we have both global rules and table transformations, will global rules get executed before table transformation?

Thanks,

Richard

RichJ
Contributor III
Contributor III
Author

Hi Hein,

Our server version is "2023.11.0.159",  but there is no "$AR_M_SOURCE_COLUMN_DATA" available in global rule configuration page.   However, I simply went ahead and used "$AR_M_SOURCE_COLUMN_DATA" , and it seemed working - I am just wondering if that's reliable for me to use it even it's not shown in the config page?

Thanks,

Richard

 

Heinvandenheuvel
Specialist III
Specialist III

@RichJ <but there is no "$AR_M_SOURCE_COLUMN_DATA" available in global rule configuration page. >

I verified just now under 2023.5.0152.

You have to select "Replace column value" along the way otherwise the "data" tab will not show.

Heinvandenheuvel_0-1710877778642.png

 

RichJ
Contributor III
Contributor III
Author

It seems to me if there are both global rule and table transformation presented, then the global rule will not be executed?  Please confirm.  Thanks!