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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
hjalmars
Contributor II
Contributor II

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 

Labels (1)
1 Solution

Accepted Solutions
hjalmars
Contributor II
Contributor II
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 II
Contributor II
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