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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Merge two values

Hi,

I need to mege two values which are existing in the same field but in last both names are different.

For example:

MyField: These values are coming in the list box

Current Output:

ABC-CDE

ABC-CDEFG

Required Output:

Required output

ABC-CDE


Both should be merge by using great method. Such as using wildmatch etc.

Note: Some times these values are greater then 7 digit

For Example: Current scenario

XYZ-AB-001

XYZ-AB-001-C1

Requried scenario:

XYZ-AB-001


Therefore, I need a method which run in all the scenarios.

regards,

23 Replies
maxgro
MVP
MVP

in my script I have 0 not 1 because match = 1 is for values I have already found

load field where match=0;

Anonymous
Not applicable
Author

Hi Massimo,

It's working fine when only one filed loaded, one I'm going to load one more field then it's not working properly.

I need to load one more field called Quantity, which consist on the values of field, which are merged to each other.

How to load field Quantity through your valuable script?

Regards,

maxgro
MVP
MVP

please post some data, or your script, I didn't understand your new requirement

Anonymous
Not applicable
Author

Hi Massimo,

Here is my sample data, I hope It will give you clear idea.

Input:

              

fieldvalue
ABC-CDE2
ABC-CDEFG2
XYZ-AB-0013
XYZ-AB-001-C13

Required Output:

fieldvalue
ABC-CDE4
XYZ-AB-0016
maxgro
MVP
MVP

a:

load *, len(field) as len inline [

field, value

ABC-CDE, 2

ABC-CDEFG, 2

XYZ-AB-001, 3

XYZ-AB-001-C1,3

AAABBB, 4

ZZZZZ, 5

ZZZ, 5

ZZZZ, 5

];

b:

load

  field,

  len,

  value,

  //if(wildmatch(field, peek(field) & '*') and len(peek(field))>0, 1, 0) as match,

  if(wildmatch(field, peek(field) & '*') and len(peek(field))>0, peek(fieldgroup), field) as fieldgroup

Resident a

order by field, len;

DROP Table a;

c:

load

  fieldgroup as field,

  sum(value) as value

Resident b

group by fieldgroup;

drop table b;

Anonymous
Not applicable
Author

Hi Massimo,

Your script working fine in inline load but when I'm going to load data from outside, then it is giving issue. I'm attaching my sample sales file "Sales.xlsx" as well as script which is modified by me. Please look into and make correction where I'm going wrong.

Sales:

LOAD *,

  len(field) as len,

  value

FROM

[Sales.xlsx]

(ooxml, embedded labels, table is Sheet1);

b:

load

  field,

  len,

  value,

  if(wildmatch(field, peek(field) & '*') and len(peek(field))>0, peek(fieldgroup), field) as fieldgroup

Resident a

order by field, len;

DROP Table Sales;

c:

load

  fieldgroup as field,

  sum(vale) as value

Resident b

group by fieldgroup;

drop table b;

Anonymous
Not applicable
Author

Hi Massimo,


Have you checked my sample file and script. please help me.

maxgro
MVP
MVP

Sales:

LOAD field, value, len(field) as len

FROM Sales.xlsx (ooxml, embedded labels, table is Sheet1);

b:

load

  field,

  len,

  value,

  if(wildmatch(field, peek(field) & '*') and len(peek(field))>0, peek(fieldgroup), field) as fieldgroup

Resident Sales

order by field, len;

DROP Table Sales;

c:

load

  fieldgroup as field,

  sum(value) as value

Resident b

group by fieldgroup;

drop table b;

1.png

Anonymous
Not applicable
Author

Dear Massimo,

I'm specially thankful to you. You help me out this problem. Now It's working fine 80%. But still I need your little bit more help for achieve 100% correction.

I attached "Sales.xlsx" and "PrecdingLoadSolution.qvw". There is littlebit mismatch between field and value.

Kindly find attached screenshot and files.

Kind regards,

Anonymous
Not applicable
Author

Hi Massimo,

Please help me to solve the issue.

Regards,