Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ananyaghosh
Creator III
Creator III

how to concatenate data in for loop

Hi I am using the below code:

Let vVarCount=RangeMax(NoOfRows('TmpSalesRep'),0);
trace $(vVarCount);

For vVar=0 to $(vVarCount)
  Let vTempName = peek('Sales Rep ID Temp',$(vVar),'TmpSalesRep');
 
  [TempSales8]:
  load  
  [Sales Rep ID] as AsOfSalesRepID8
  resident [TmpTable]
  where
    [Process Date] >= '$(vPrevEightYearStartDate)' and
      [Process Date] <= '$(vPrevYearEndDate)' and
       [Sales Amount USD]=0 and
      [Sales Rep ID] = '$(vTempName)';
     
      if(NoOfRows('TempSales8')>0) then
      Let ID = '$(vTempName)'&; //I want to concatenate the '$(vTempName)' values as '1234','2015', '5679'
      end if
 
Next vVar

I am using this code: Let ID = '$(vTempName)'&;

and I want to concatenate the '$(vTempName)' values as '1234','2015', '5679'

So can u give me the correct syntax?

1 Solution

Accepted Solutions
maxgro
MVP
MVP

add at the end of the script

LET ID = chr(39) & Replace('$(ID)', ',', chr(39) & ',' & chr(39)) & chr(39);

trace $(ID);

View solution in original post

3 Replies
maxgro
MVP
MVP

For vVar=0 to $(vVarCount)-1

      if(NoOfRows('TempSales8')>0) then

           Let ID = IF(len('$(ID)')>0, '$(ID)' & ',') & '$(vTempName)' ;

      end if

ananyaghosh
Creator III
Creator III
Author

Hi,

it works but, Can it be make as:

'12','14', '16' like that?

Currently it is 12,13,14.

Also if you help me for one of my previous post:

sum({&lt;[Process Date]={"$(=date(max([Process Date])-1,'MM/DD/YYYY'))"}&gt;}[Sales Posting Amount U...

As I am facing problem with Week and year calculations?

Thanks,

Sandip

maxgro
MVP
MVP

add at the end of the script

LET ID = chr(39) & Replace('$(ID)', ',', chr(39) & ',' & chr(39)) & chr(39);

trace $(ID);