Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

sakshikaul
Contributor

Combining two functions together in scripting

Dear all Following are the two tables and I want to combine two functionalities in one table so for that how to write the script? Basically I have to combine mid function and if conditions stated below LOAD *, Mid(LABNAME,1,index(LABNAME,'-',1)-1) as Lab_Code, Mid(LABNAME,index(LABNAME,'-',1)+1,index(LABNAME,'-',2)-index(LABNAME,'-',1)-1) as Lab_Location, Mid(LABNAME, index(LABNAME,'-',2)+1, Len(LABNAME)-index(LABNAME,'-',2)) as Lab_Zone; SQL SELECT ANALYTE, CITY, Comment, CorrectiveAction, ExpiredDate, FixedCV, FixedMean, FixedSD, from xyz.dbo.xyz; LOAD *, if(LABID = '166051','S03', if(Match(LABID,'180128','180130','180132','180138','180140','180142','180144','180148','180150','180152','180154','180156','180163'), 'L51','LPL')) as Lab_Code, if(LABID = '166051','Preet Vihar', if(Match(LABID,'180128','180130','180132','180138','180140','180142','180144','180148','180150','180152','180154','180156','180163'),'KRL','NRL')) as Lab_Location, if(LABID = '166051','DNCR', if(Match(LABID,'180128','180130','180132','180138','180140','180142','180144','180148','180150','180152','180154','180156','180163'),'KRL','NRL')) as Lab_Zone; SQL SELECT ANALYTE, CITY, Comment, CorrectiveAction, ExpiredDate, FixedCV, FixedMean, FixedSD from xyz.dbo.xyz;
2 Replies
lockematthewp
Contributor II

Re: Combining two functions together in scripting

Just add the 'join' keyword between the tables.

LOAD *, Mid(LABNAME,1,index(LABNAME,'-',1)-1) as Lab_Code, Mid(LABNAME,index(LABNAME,'-',1)+1,index(LABNAME,'-',2)-index(LABNAME,'-',1)-1) as Lab_Location, Mid(LABNAME, index(LABNAME,'-',2)+1, Len(LABNAME)-index(LABNAME,'-',2)) as Lab_Zone; SQL SELECT ANALYTE, CITY, Comment, CorrectiveAction, ExpiredDate, FixedCV, FixedMean, FixedSD, from xyz.dbo.xyz;

join

LOAD *, if(LABID = '166051','S03', if(Match(LABID,'180128','180130','180132','180138','180140','180142','180144','180148','180150','180152','180154','180156','180163'), 'L51','LPL')) as Lab_Code, if(LABID = '166051','Preet Vihar', if(Match(LABID,'180128','180130','180132','180138','180140','180142','180144','180148','180150','180152','180154','180156','180163'),'KRL','NRL')) as Lab_Location, if(LABID = '166051','DNCR', if(Match(LABID,'180128','180130','180132','180138','180140','180142','180144','180148','180150','180152','180154','180156','180163'),'KRL','NRL')) as Lab_Zone; SQL SELECT ANALYTE, CITY, Comment, CorrectiveAction, ExpiredDate, FixedCV, FixedMean, FixedSD from xyz.dbo.xyz;

Support
Support

Re: Combining two functions together in scripting

Did the last poster's comment help you resolve things?  If so, please be sure to use the Accept as Solution button to give them credit for the help.  If you are still working on things, let us know where you are still stuck.  

Below is a link that may help a little as well, there are also hundreds of other posts in this area, so be sure to search there in more detail if this one does not do the trick:

https://community.qlik.com/t5/Qlik-Design-Blog/To-Join-or-not-to-Join/ba-p/1463102

Regards,
Brett

To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.