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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
vvvvvvizard
Partner - Specialist
Partner - Specialist

Create expression dynamically

I know from the backend that there will be 7 of these fields but could change to 8 , 9 ect the value vcount says the number

LET  vcount = NoOfRows('Fields_Mapping');   // say its 7

if vcount is 7 you need to generate the string below that i can use on the front end

so im expecting let vMakeexpression=repeat().......smtng smnng to get the below string .

=if(not isnull([Checklist Phase 7]), [Checklist Phase 7],

if(not isnull([Checklist Phase 6]), [Checklist Phase 6],

if(not isnull([Checklist Phase 5), [Checklist Phase 5],

if(not isnull([Checklist Phase 4]), [Checklist Phase 4],

if(not isnull([Checklist Phase 3]), [Checklist Phase 3],

if(not isnull([Checklist Phase 2]), [Checklist Phase 2],

if(not isnull([Checklist Phase 1]), [Checklist Phase 1]

)))))))

1 Solution

Accepted Solutions
sunny_talwar

Try this

LET vCount = NoOfRows('Fields_Mapping');;


Temp:

LOAD Concat(Temp, ',', -RowNo) & Repeat(')', $(vCount)) as String;

LOAD IterNo() as RowNo,

'If(not isnull([Checklist Phase ' & IterNo() &']), [Checklist Phase ' & IterNo() & ']' as Temp

AutoGenerate 1

While IterNo() <= $(vCount);


LET vMakeexpression = Peek('String');

View solution in original post

1 Reply
sunny_talwar

Try this

LET vCount = NoOfRows('Fields_Mapping');;


Temp:

LOAD Concat(Temp, ',', -RowNo) & Repeat(')', $(vCount)) as String;

LOAD IterNo() as RowNo,

'If(not isnull([Checklist Phase ' & IterNo() &']), [Checklist Phase ' & IterNo() & ']' as Temp

AutoGenerate 1

While IterNo() <= $(vCount);


LET vMakeexpression = Peek('String');