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: 
anwarbham
Contributor III
Contributor III

Qlik Only function with sub functions

hi , i am trying to limit a dimension based on the selected filter of year 

if some one selcts 2019 then i should only see 

records from 2019 

eg 

 01/01/2019 - 30/04/2019

i am trying to use the ONLY function to get only the records where the last 4 digits are 2019, but i get the error i can only use 1 parameter, Can anyone help with the syntax 

if (
GetCurrentSelections(Year) = '2019',

Only(right([Cycle Generic],4)= '2019',[Cycle Generic])

)

  

Labels (3)
3 Replies
Kushal_Chawda
MVP
MVP

@anwarbham  may be try below

if (
GetCurrentSelections(Year) = '2019' and

right([Cycle Generic],4)= '2019',[Cycle Generic])

)
anwarbham
Contributor III
Contributor III
Author

Thanks

this works but if i select both 2019 and 2020 it does not work regardless if i add a match([Cycle Generic], '2019','2020')

 

=if (
GetFieldSelections(Year) = '2019' and
right([Cycle Generic],4) = '2019'
,[Cycle Generic],

if(
GetFieldSelections(Year) = '2020' and 
right([Cycle Generic],4) = '2020',
[Cycle Generic]

))

 

 

paulselousyoriz
Partner - Contributor III
Partner - Contributor III

That is because if you select more than one Year, then GetFieldSelections(Year) will return the selected values with a comma inbetween, so in your example '2019,2020', which does not equal '2019' nor '2020'. You can solve this with a wildmatch with wildcard characters:

If(wildmatch(GetFieldSelections(Year),'*2019*','*2020*')>0 and
(right([Cycle Generic],4)='2019' Or right([Cycle Generic],4)='2020'),[Cycle Generic])

 

Hope that helps!

Paul