Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have the following application where:
What it does: (see image below)
How we do it:
vTotalTransactionsSet1 =
sum({<
[AuthorisationDate] = {'>=$(=Date(vStartDate1))<=$(=Date(vEndDate1))'},
[Authorisations Year] = [Group1]::[Authorisations Year],
[Authorisations Quarter] = [Group1]::[Authorisations Quarter],
[Authorisations Month] = [Group1]::[Authorisations Month],
[Authorisations Week] = [Group1]::[Authorisations Week],
[Authorisations Day] = [Group1]::[Authorisations Day],
[TerminalsID] = {'<> 00'},
[TransactionAmmount] = {'> 0'}
>} AuthorisationRec)
What can be improved:
if($(vTotalTransactionsSet2) > $(vTotalTransactionsSet1), Green(), Red()))
e.g. = ($(vTotalTransactionsSet2) - $(vTotalTransactionsSet1)) / $(vTotalTransactionsSet1)
if($(vTotalTransactionsSet2) > $(vTotalTransactionsSet1), Green(), Red()))
THERE HAS TO BE MORE EFFICIENT WAYS OF DOING THIS, SURELY
I await your suggestions with baited breath
Thanks in advance
Alexis
By putting an = character in front of an expression in a variable it will be calculated outside the context of the object the variable is used in. So you can try this:
vTotalTransactionsSet1:
=sum({<
[AuthorisationDate] = {'>=$(=Date(vStartDate1))<=$(=Date(vEndDate1))'},
[Authorisations Year] = [Group1]::[Authorisations Year],
[Authorisations Quarter] = [Group1]::[Authorisations Quarter],
[Authorisations Month] = [Group1]::[Authorisations Month],
[Authorisations Week] = [Group1]::[Authorisations Week],
[Authorisations Day] = [Group1]::[Authorisations Day],
[TerminalsID] = {'<> 00'},
[TransactionAmmount] = {'> 0'}
>} AuthorisationRec)
Also, Qlikview will cache results from calculated expressions. So if you reuse an expression in a chart then Qlikview will get the results from the cache. This also applies to reusing expressions in different text boxes. If the context is the same then the expression will return the same result so the value can be retrieved from the cache. No performance penalty there.
Hi Gysbert,
Thanks for taking the time to respond. If you look at my original posting my variable definition DOES have an "=" sign...
e.g.
vTotalTransactionsSet1 =
sum({<
[AuthorisationDate] .....
Let me cover fully, just one of the KPIs as a way of explanation - maybe you'll detect something that I am doing wrong in my implementation:
KPI: Average transactions per MID
Result1: (this is the result for date set Group1):
= num($(vTotalTransactionsSet1) / $(vTotalUniqueMIDsSet1), '#.##0,00')
where
vTotalTransactionsSet1 is defined as:
= sum({< [AuthorisationDate] = {'>=$(=Date(vStartDate1))<=$(=Date(vEndDate1))'},
[Authorisations Year] = [Group1]::[Authorisations Year],
[Authorisations Quarter] = [Group1]::[Authorisations Quarter],
[Authorisations Month] = [Group1]::[Authorisations Month],
[Authorisations Week] = [Group1]::[Authorisations Week],
[Authorisations Day] = [Group1]::[Authorisations Day],
[TerminalsID] = {'<> 00'},
[TransactionAmmount] = {'> 0'}
>} AuthorisationRec)
vTotalUniqueMIDsSet1 is defined as:
=count({<[AuthorisationDate] = {'>=$(=Date(vStartDate1))<=$(=Date(vEndDate1))'},
[Authorisations Year] = [Group1]::[Authorisations Year],
[Authorisations Quarter] = [Group1]::[Authorisations Quarter],
[Authorisations Month] = [Group1]::[Authorisations Month],
[Authorisations Week] = [Group1]::[Authorisations Week],
[Authorisations Day] = [Group1]::[Authorisations Day],
[TerminalsID] = {'<> 00'},
[TransactionAmmount] = {'> 0'}
>} distinct Authorisations_MerchantID)
Result2: This is almost identical to Result 1 just replacing [Group1] for [Group2] and the vStartDate1 and vEndDate1 with their equivalents: vStart2 and EndDate2
Result3: This is defined as:
= if($(vAverageTransactionsPerMID_Compare)= 0,'arrow-level-blue.png',
if($(vAverageTransactionsPerMID_Compare)= 1, 'arrow-down-red.png', 'arrow-up-green.png'))
where:
vAverageTransactionsPerMID_Compare is defined as:
= if(
($(vTotalTransactionsSet2) / $(vTotalUniqueMIDsSet2)) =
($(vTotalTransactionsSet1) / $(vTotalUniqueMIDsSet1)) ,0,
if(
($(vTotalTransactionsSet2) / $(vTotalUniqueMIDsSet2)) >
($(vTotalTransactionsSet1) / $(vTotalUniqueMIDsSet1)) ,2,1))
Result4:
=num(
((($(vTotalTransactionsSet2) / $(vTotalUniqueMIDsSet2))
-
($(vTotalTransactionsSet1) / $(vTotalUniqueMIDsSet1))
) /
($(vTotalTransactionsSet1) / $(vTotalUniqueMIDsSet1))
), '#.##0,00%')