Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
hjalmars
Contributor
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
Contributor
Contributor
Author

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

View solution in original post

2 Replies
felipedl
Partner - Specialist III
Partner - Specialist III

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
Contributor
Contributor
Author

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