Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

hjalmars
New Contributor

Variables - Passing a String as an argument

Hi all,

I have 2 variables defined as follows:

vBenchmarks
fractile( {$<Konto = $1, [Benchmark.Liegenschaftstyp] = {$(vLiegenschaftstyp)} , [Benchmark.Bewertungsjahr] = $(vReport_Jahr) >} [Benchmark.Wert] , $2)

vLiegenschaftstyp
chr(39)&[Bewertung.Liegenschaftstyp]&chr(39)

The field [Bewertung.Liegenschaftstyp] contains strings such as 'Wohnen', 'Geschäft/Büro',...

My variable vBenchmarks is not giving an output. However the output is correctly calculated if I use this expression instead: 

fractile( {$<Konto = $1, [Benchmark.Liegenschaftstyp] = {'Wohnen'} , [Benchmark.Bewertungsjahr] = $(vReport_Jahr) >} [Benchmark.Wert] , $2) 

Therefore the problem must arise when passing the variable vLiegenschaftstyp to vBenchmarks. What can I do to make it work? I assume it has to do something with string formating? 

I tried nearly all possible variants to define vLiegenschaftstyp:
[Bewertung.Liegenschaftstyp], =[Bewertung.Liegenschaftstyp], text([Bewertung.Liegenschaftstyp]), =text([Bewertung.Liegenschaftstyp]),...

Thanks in advance
Hjalmar 

1 Solution

Accepted Solutions
hjalmars
New Contributor

Re: Variables - Passing a String as an argument

Thanks, this sounds absolutely reasonable, however it didn't work in my particular case for some reason. In the meantime I found out that this works surprisingly: 

vLiegenschaftstyp:
chr(123)&chr(39)&[Bewertung.Liegenschaftstyp]&chr(39)&chr(125)

vBenchmarks:
= fractile( {$<Konto =  $1, [Benchmark.Liegenschaftstyp] = $($(vLiegenschaftstyp)), [Benchmark.Bewertungsjahr] = $(vReport_Jahr) >} [Benchmark.Wert]  ,  $2)

But still I'm not really able to understand why making a double $-sign expansion helps...

Best Regards

2 Replies
Partner
Partner

Re: Variables - Passing a String as an argument

Try changing the expression to this:

 

fractile( {$<Konto = $1, [Benchmark.Liegenschaftstyp] = {'$(vLiegenschaftstyp)'} , [Benchmark.Bewertungsjahr] = $(vReport_Jahr) >} [Benchmark.Wert] , $2)

When you pass the variable, lets say 'Wohnen', the param is passed withouth the apostrophes, giving you an incomplete set analysis, like below:

expression('Wohnen') gives as a result for the set analysis:

fractile( {$<Konto = $1, [Benchmark.Liegenschaftstyp] = {Wohnen} , [Benchmark.Bewertungsjahr] = $(vReport_Jahr) >} [Benchmark.Wert] , $2)

 

hjalmars
New Contributor

Re: Variables - Passing a String as an argument

Thanks, this sounds absolutely reasonable, however it didn't work in my particular case for some reason. In the meantime I found out that this works surprisingly: 

vLiegenschaftstyp:
chr(123)&chr(39)&[Bewertung.Liegenschaftstyp]&chr(39)&chr(125)

vBenchmarks:
= fractile( {$<Konto =  $1, [Benchmark.Liegenschaftstyp] = $($(vLiegenschaftstyp)), [Benchmark.Bewertungsjahr] = $(vReport_Jahr) >} [Benchmark.Wert]  ,  $2)

But still I'm not really able to understand why making a double $-sign expansion helps...

Best Regards