Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get proper formula in the QV Script?

Dear All,

I need to redefine one of my QV dimensions, using other dimensions loaded. The simplest way would be to do this directly in the load script, however being able to get what I want in excel (attached) by writting appropriate formula, I am not able to mirror this in QV script.

Can anyone help me to convert the excel loginc into the QV script logic?

thanks a lot in advance

1 Solution

Accepted Solutions
jyothish8807
Master II
Master II

Hi,

I am really sorry got confused with that function .

replace it with:

if(Product_Type='Finished good' and wildMatch(Sub_Product_Name,'*/*')>0,subfield(Sub_Product_Name,'/',1)&'-'& Size_Name,if(Product_Type='Finished good' and wildMatch(Sub_Product_Name,'*/*')<0,subfield (Sub_Product_Name,' ',1) &'-'& Size_Name),Sub_Product_Name))


Regards

KC

Best Regards,
KC

View solution in original post

8 Replies
jyothish8807
Master II
Master II

Hi Draszor,

Try something like this:

if(Product_Type='Finished good',substring(Sub_Product_Name,'/',1)&'-'& Size_Name,Sub_Product_Name)

Regards

KC

Best Regards,
KC
Not applicable
Author

thanks a lot, but I need as well the part for non Finished goods...

The formula basically says that:

  • If Product Type = Finished good and sub product name contains "/", then take the text until the "/" sign
  • Otherise, then take the text until the " " sign in Sub_Product_Name  or if " " sign does not exist, take the whole string from Sub_Product_Name
  • add the Size_Name for Finished goods
Not applicable
Author

Probably need to nest that if for all that, but definitely doable in QV

jyothish8807
Master II
Master II

Hi ,

Try this:

if(Product_Type='Finished good' and wildMatch(Sub_Product_Name,'*/*')>0,substring(Sub_Product_Name,'/',1)&'-'& Size_Name,if(Product_Type='Finished good' and wildMatch(Sub_Product_Name,'*/*')<0,substring (Sub_Product_Name,' ',1) &'-'& Size_Name),Sub_Product_Name))

Regards

KC

Best Regards,
KC
Not applicable
Author

the Substring(field,'/',1) does not work. I tied to set it as separate variable and it does not work as well - the synthax is wrong...

From your example i conclude that the synthax you meant was:

substring(field, end of the string expression,start at), returning for "KRToo/oodd' the"KTR oo" one.

I could not find in any help materials that such synthax exists for substring expression.

jyothish8807
Master II
Master II

Hi,

I am really sorry got confused with that function .

replace it with:

if(Product_Type='Finished good' and wildMatch(Sub_Product_Name,'*/*')>0,subfield(Sub_Product_Name,'/',1)&'-'& Size_Name,if(Product_Type='Finished good' and wildMatch(Sub_Product_Name,'*/*')<0,subfield (Sub_Product_Name,' ',1) &'-'& Size_Name),Sub_Product_Name))


Regards

KC

Best Regards,
KC
Not applicable
Author

thanks a lot KC,

now thi worked - I needed to do very few editorial changes like:

Instead of wildMatch(Sub_Product_Name,'*/*')<0

I used wildMatch(Sub_Product_Name,'*/*')=0

or I added the proper part of the formula for non Finished goods, but your code was 98% ready.

Very helpful, very quick, I am very glad

thanks

Regards

Rob

jyothish8807
Master II
Master II


You are welcome Rob Actually i didnt try that syntex in app, i just wrote that so coudnt track my mistakes

Regards

KC

Best Regards,
KC