Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mkts
Contributor
Contributor

Moving a string marker

I've been tasked with writing a script that auto-inserts '>>' '<<' markers where certain keywords are found, in the absence of the ability to apply bold or colour highlights to them. Some of these keywords are truncated to maximise the number of combinations dredged up, eg., "investigat" retrieves "investigation", "investigated", "investigating" etc, without having to load all the different words separately.

In a table, the data currently appears like this:

... An >>investigat<<ion has been opened...

And I'd like to modify the script so it appears as:

... An >>investigation<< has been opened...

When keywords aren't truncated, it operates as normal. I've tried putting '?' wildcards in the source file, but it causes the keywords to be ignored. I'm pretty sure it's simpler than it looks, as I'm prone to over-thinking.

I use the following script with a mapping load to insert the markers:

 

mapRedactions:
Mapping Load
    RedactKeyword,
    '>>' & RedactKeyword & '<<'
Resident Redaction_Keywords;
Mapping Load
    Capitalize(RedactKeyword) as RedactKeyword,
    '>>' & Capitalize(RedactKeyword) & '<<'
Resident Redaction_Keywords;
Mapping Load
    Upper(RedactKeyword) as RedactKeyword,
    '>>' & Upper(RedactKeyword) & '<<'
Resident Redaction_Keywords;

Reasons_Redactions:
NoConcatenate Load
	%goAML_Report_ID,
        MapSubString('mapRedactions', RedactedReasonForSuspicion)
    	as RedactedReasonForSuspicion
Resident RFS;

 

 

 

 

 

Labels (3)
5 Replies
HeshamKhja1
Partner - Creator II
Partner - Creator II

I am expecting that the mapping table you are loading is manually created to be able to retrieve all possible outcomes, right?

I think if you add another column in the mapping table that has the output you need, then it will work fine.

Example:

Redaction_Keywords:
LOAD * Inline [
TruncatedValue, Value
Investigat, Investigation
];

mapRedactions:
Mapping LOAD
   TruncatedValue,
   '>>' & Value & '<<'
RESIDENT Redaction_Keywords;

 

vincent_ardiet_
Specialist
Specialist

If your keywords doesn't have spaces, you can maybe first insert "<<" with your current method. And then in a second time, locate the << and find the next space where you can insert <<.
But if you can have multiple occurrences in your string, this will not work. 

marcus_sommer

You may apply a nested mapsubstring() and the outer mapping goes to data like:

m: mapping load * inline [
L, R
<<ion, ion<<
<<ed, ed<<
<<ing, ing<<
];

mkts
Contributor
Contributor
Author

Thanks for the advice so far. At this stage I'm using nested Replace() functions in the MapSubstring, while I work out a more elegant solution. If that doesn't work out, I'll stick with nested Replace().

marcus_sommer

Did you really an attempt with a nested mapsubstring ? It should work. If it are only these 3 replacements a nested replace-approach is surely practically enough but if it are more it could become ugly.