<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Evaluate field as formula within script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1568019#M596575</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I really like your solution and for the case I showed above it works perfectly.&lt;BR /&gt;I made a small adaption for the case that the list of phrases that must be included contains more than one word.&lt;/P&gt;&lt;PRE&gt;Stringtable:
LOAD *, recno() as ID;
LOAD * INLINE [
    String_to_check, cannot_be_included, must_be_included, condition
    'aa bb cd efg', "'*a*','*ef*'", "'*bb*'", "WildMatch(String_to_check,'*a*','*ef*')&amp;gt;0 OR WildMatch(String_to_check,'*bb*')=0"
    'ase', "'*a*','*ef*','*zzz*'", "'*vv*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0"
    'yyy vvv', "'*a*','*ef*','*zzz*'", "'*vv*','*yy*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0 OR WildMatch(String_to_check,'*yy*')=0"
    'yyy vvv', "'*a*','*ef*','*zzz*'", "'*vv*','*zz*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0 OR WildMatch(String_to_check,'*zz*')=0"
    'asd', "'*a*','*ef*','*zzz*'", , "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0"
    'ase', , "'*vv*'", "WildMatch(String_to_check,'*vv*')=0" 
];

cannot_be_included:
load ID,
	 sub_cannot_be_included,
	 WildMatch(String_to_check, sub_cannot_be_included) as flag_cannot_be_included;
load ID,
	 String_to_check,
	 PurgeChar(subfield(cannot_be_included, ','), chr(39)) AS sub_cannot_be_included     
Resident Stringtable;

must_be_included:
load ID,
	 sub_must_be_included,
	 if(WildMatch(String_to_check, sub_must_be_included),0,1) as flag_must_be_included;
load ID,
	 String_to_check,
	 PurgeChar(subfield(must_be_included, ','), chr(39)) AS sub_must_be_included
Resident Stringtable;

join(Stringtable)
load ID,
	 Max(flag_cannot_be_included) as flag_cannot_be_included
Resident cannot_be_included
group by ID;

join(Stringtable)
load ID,
	 Max(flag_must_be_included) as flag_must_be_included
Resident must_be_included
group by ID;

drop tables must_be_included, cannot_be_included;

join(Stringtable)
load ID,
	 if (not flag_cannot_be_included and not flag_must_be_included, 'Correct', 'Incorrect') AS Result
resident Stringtable;&lt;/PRE&gt;&lt;P&gt;______________________________________________________&lt;/P&gt;&lt;P&gt;Additional information for users that might have the same problems as I had, I figured out how evaluate() can handle a formula:&lt;/P&gt;&lt;P&gt;So this doesn't work:&lt;/P&gt;&lt;P&gt;evaluate("If(WildMatch(' aa bb cd efg ','*a*','*ef*')&amp;gt;0 OR WildMatch(' aa bb cd efg ','*bb*')=0,'incorrect','correct')")&lt;BR /&gt;evaluate([If(WildMatch(' aa bb cd efg ','*a*','*ef*')&amp;gt;0 OR WildMatch(' aa bb cd efg ','*bb*')=0,'incorrect','correct')])&lt;BR /&gt;evaluate(´If(WildMatch(' aa bb cd efg ','*a*','*ef*')&amp;gt;0 OR WildMatch(' aa bb cd efg ','*bb*')=0,'incorrect','correct')´)&lt;/P&gt;&lt;P&gt;but this does:&lt;BR /&gt;evaluate('If(WildMatch('' aa bb cd efg '',''*a*'',''*ef*'')&amp;gt;0 OR WildMatch(''&amp;nbsp;aa bb cd efg '',''*bb*'')=0,''incorrect'',''correct'')')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Apr 2019 08:30:54 GMT</pubDate>
    <dc:creator>winnes</dc:creator>
    <dc:date>2019-04-11T08:30:54Z</dc:date>
    <item>
      <title>Evaluate field as formula within script</title>
      <link>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1567454#M596573</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I would like to evaluate a string in a field as an expression within the script.&lt;/P&gt;&lt;P&gt;More specifically I have the following table&lt;/P&gt;&lt;PRE&gt;Stringtable: &lt;BR /&gt;LOAD * INLINE [
    String_to_check, cannot_be_included, must_be_inclued, condition
    'aa bb cd efg', "'*a*','*ef*'", "'*bb*'", "WildMatch(String_to_check,'*a*','*ef*')&amp;gt;0 OR WildMatch(String_to_check,'*bb*')=0"
    'ase', "'*a*','*ef*','*zzz*'", "'*vv*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0"
    'yyy vvv', "'*a*','*ef*','*zzz*'", "'*vv*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0"
    'asd', "'*a*','*ef*','*zzz*'", , "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0"
    'ase', , "'*vv*'", "WildMatch(String_to_check,'*vv*')=0" 
];&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unbenannt.JPG" style="width: 819px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/9849iE282ACD423FB01A0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.JPG" alt="Unbenannt.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now I want to have another field column that contains the values 'incorrect' and 'correct' depending on whether the string "String_to_check" hurts the condition in the "condition" column:&lt;/P&gt;&lt;PRE&gt;LOAD * INLINE [ String_to_check, Result
'aa bb cd efg', 'incorrect'
'ase', 'incorrect'
'yyy vvv', 'correct'
'asd', 'incorrect'
'ase', 'incorrect'
];&lt;/PRE&gt;&lt;P&gt;It is important that this creation of "Result" is made in the script itself as I need to use this column further later in the script.&lt;/P&gt;&lt;P&gt;I tried using the following code, but evaluate() returns Null-Values as it doesn't detect the condition as a valid formula.&lt;/P&gt;&lt;PRE&gt;Stringtable_with_Result:
LOAD
	*,
	If(num(evaluate(condition)),'incorrect','correct') 	AS Result
RESIDENT Stringtable;
drop table Stringtable;&lt;/PRE&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 21:04:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1567454#M596573</guid>
      <dc:creator>winnes</dc:creator>
      <dc:date>2024-11-16T21:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate field as formula within script</title>
      <link>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1567905#M596574</link>
      <description>&lt;P&gt;Assuming you can't change the Stringtable input data - I didn't use the "condition"field...&lt;/P&gt;&lt;PRE&gt;Stringtable:
LOAD *, recno() as ID;
LOAD * INLINE [
    String_to_check, cannot_be_included, must_be_inclued, condition
    'aa bb cd efg', "'*a*','*ef*'", "'*bb*'", "WildMatch(String_to_check,'*a*','*ef*')&amp;gt;0 OR WildMatch(String_to_check,'*bb*')=0"
    'ase', "'*a*','*ef*','*zzz*'", "'*vv*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0"
    'yyy vvv', "'*a*','*ef*','*zzz*'", "'*vv*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0"
    'asd', "'*a*','*ef*','*zzz*'", , "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0"
    'ase', , "'*vv*'", "WildMatch(String_to_check,'*vv*')=0" 
];

cannot_be_included:
load ID,
	 sub_cannot_be_included,
	 WildMatch(String_to_check, sub_cannot_be_included) as flag_cannot_be_included;
load ID,
	 String_to_check,
	 PurgeChar(subfield(cannot_be_included, ','), chr(39)) AS sub_cannot_be_included     
Resident Stringtable;

must_be_inclued:
load ID,
	 sub_must_be_inclued,
	 WildMatch(String_to_check, sub_must_be_inclued) as flag_must_be_inclued;
load ID,
	 String_to_check,
	 PurgeChar(subfield(must_be_inclued, ','), chr(39)) AS sub_must_be_inclued
Resident Stringtable;

join(Stringtable)
load ID,
	 Max(flag_cannot_be_included) as flag_cannot_be_included
Resident cannot_be_included
group by ID;

join(Stringtable)
load ID,
	 Max(flag_must_be_inclued) as flag_must_be_inclued
Resident must_be_inclued
group by ID;

drop tables must_be_inclued, cannot_be_included;

join(Stringtable)
load ID,
	 if (not flag_cannot_be_included and flag_must_be_inclued, 'Correct', 'Incorrect') AS Result
resident Stringtable;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 00:26:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1567905#M596574</guid>
      <dc:creator>fosuzuki</dc:creator>
      <dc:date>2019-04-11T00:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate field as formula within script</title>
      <link>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1568019#M596575</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I really like your solution and for the case I showed above it works perfectly.&lt;BR /&gt;I made a small adaption for the case that the list of phrases that must be included contains more than one word.&lt;/P&gt;&lt;PRE&gt;Stringtable:
LOAD *, recno() as ID;
LOAD * INLINE [
    String_to_check, cannot_be_included, must_be_included, condition
    'aa bb cd efg', "'*a*','*ef*'", "'*bb*'", "WildMatch(String_to_check,'*a*','*ef*')&amp;gt;0 OR WildMatch(String_to_check,'*bb*')=0"
    'ase', "'*a*','*ef*','*zzz*'", "'*vv*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0"
    'yyy vvv', "'*a*','*ef*','*zzz*'", "'*vv*','*yy*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0 OR WildMatch(String_to_check,'*yy*')=0"
    'yyy vvv', "'*a*','*ef*','*zzz*'", "'*vv*','*zz*'", "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0 OR WildMatch(String_to_check,'*vv*')=0 OR WildMatch(String_to_check,'*zz*')=0"
    'asd', "'*a*','*ef*','*zzz*'", , "WildMatch(String_to_check,'*a*','*ef*','*zzz*')&amp;gt;0"
    'ase', , "'*vv*'", "WildMatch(String_to_check,'*vv*')=0" 
];

cannot_be_included:
load ID,
	 sub_cannot_be_included,
	 WildMatch(String_to_check, sub_cannot_be_included) as flag_cannot_be_included;
load ID,
	 String_to_check,
	 PurgeChar(subfield(cannot_be_included, ','), chr(39)) AS sub_cannot_be_included     
Resident Stringtable;

must_be_included:
load ID,
	 sub_must_be_included,
	 if(WildMatch(String_to_check, sub_must_be_included),0,1) as flag_must_be_included;
load ID,
	 String_to_check,
	 PurgeChar(subfield(must_be_included, ','), chr(39)) AS sub_must_be_included
Resident Stringtable;

join(Stringtable)
load ID,
	 Max(flag_cannot_be_included) as flag_cannot_be_included
Resident cannot_be_included
group by ID;

join(Stringtable)
load ID,
	 Max(flag_must_be_included) as flag_must_be_included
Resident must_be_included
group by ID;

drop tables must_be_included, cannot_be_included;

join(Stringtable)
load ID,
	 if (not flag_cannot_be_included and not flag_must_be_included, 'Correct', 'Incorrect') AS Result
resident Stringtable;&lt;/PRE&gt;&lt;P&gt;______________________________________________________&lt;/P&gt;&lt;P&gt;Additional information for users that might have the same problems as I had, I figured out how evaluate() can handle a formula:&lt;/P&gt;&lt;P&gt;So this doesn't work:&lt;/P&gt;&lt;P&gt;evaluate("If(WildMatch(' aa bb cd efg ','*a*','*ef*')&amp;gt;0 OR WildMatch(' aa bb cd efg ','*bb*')=0,'incorrect','correct')")&lt;BR /&gt;evaluate([If(WildMatch(' aa bb cd efg ','*a*','*ef*')&amp;gt;0 OR WildMatch(' aa bb cd efg ','*bb*')=0,'incorrect','correct')])&lt;BR /&gt;evaluate(´If(WildMatch(' aa bb cd efg ','*a*','*ef*')&amp;gt;0 OR WildMatch(' aa bb cd efg ','*bb*')=0,'incorrect','correct')´)&lt;/P&gt;&lt;P&gt;but this does:&lt;BR /&gt;evaluate('If(WildMatch('' aa bb cd efg '',''*a*'',''*ef*'')&amp;gt;0 OR WildMatch(''&amp;nbsp;aa bb cd efg '',''*bb*'')=0,''incorrect'',''correct'')')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 08:30:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Evaluate-field-as-formula-within-script/m-p/1568019#M596575</guid>
      <dc:creator>winnes</dc:creator>
      <dc:date>2019-04-11T08:30:54Z</dc:date>
    </item>
  </channel>
</rss>

