Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I'm working on a ad-hoc table in a Qlik Sense app. Things are working pretty good but i'm strugling with the following and I hope somebody can help me out.
I have a dimension table i use to select the dimensions for my table:
Dimension:
DimID, Dimensie
1, Klant
2, Omzetgroep
3, Omzetgroep2
To show/hide a dimension i've added the following expression:
Dimension = Klant
SubStringCount(GetFieldSelections(Dimensie,',','20'),'Klant')
Dimension = Omzetgroep
SubStringCount(GetFieldSelections(Dimensie,',','20'),'Omzetgroep')
Dimension = Omzetgroep2
SubStringCount(GetFieldSelections(Dimensie,',','20'),'Omzetgroep2')
For the dimension = Klant this works like a charm but for the other two there is an issue. If I select dimension = Omzetgroep2 then both (Omzetgroep and Omzetgroep2) are shown in the table. I can't figure out how to fix this so Omzetgroep is only shown when actually selected in the dimension filter.
Thank you again for letting me pick your brain for a minute 🙂
Hi,
I think the issue is that Omzetgroep is contained in Omzetgroep2, hence your SubStringCount gets a match you didn't intend. You can try making it not match by adding something to the beginning and end of the string to search and being searched that is not in the string to force an exact match, so maybe;
SubStringCount('#'&GetFieldSelections(Dimensie,'#,#','20')&'#','#Omzetgroep#')
Cheers,
Chris.
Hi,
I think the issue is that Omzetgroep is contained in Omzetgroep2, hence your SubStringCount gets a match you didn't intend. You can try making it not match by adding something to the beginning and end of the string to search and being searched that is not in the string to force an exact match, so maybe;
SubStringCount('#'&GetFieldSelections(Dimensie,'#,#','20')&'#','#Omzetgroep#')
Cheers,
Chris.
You shouldn't be using substring count to find a match.
1) I assume it's not an always one selected field, if so it's as easy as only([Dimensie]) = 'Omzetgroep2'
You can do either of these for each column field, both should work but i'd choose the 2nd option:
=match('Omzetgroep2', $(=chr(39) & getfieldselections(Dimensie, chr(39) & ', ' & chr(39)) & chr(39)))
or
=getselectedcount(Dimensie)>0 and match(2, $(=concat(distinct DimID, ', ')))
Hi Chris,
Your solution makes sense and is just what I was looking for.
Works like a charm, thank you!
Grtz, Tamarah
Hi,
Thank you for sharing your ideas!
I've accepted the sollution provided by Chris but I've tested your options and your first option works just fine! When trying the 2nd option I do get an error in the expression. Since I have 2 working options and no spare time 😉 I will leave it to this.
Thnx again!
Grtz, Tamarah