Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I am weighting scores for each phase of an account that we manage. The weight of each phase depends on the current phase that the account is in (see attachment file "Phases"). There are 4 phases and an account can only be in one phase at a given time, but will have a score for each of the previous phases it's gone through.
So, in my code I create a mapping for each of the weight breakdowns and then use the ApplyMap function to choose the corresponding table and value to bring back. Then, I multiply the weight by the original score of the phase, thus giving me a weighted score. I was dynamically setting the table (map_id Expression) in the ApplyMap function prior to the Qlik Sense 3.0 upgrade, but now I receive an "Unknown Error". I've attached a simplified version of my code to show what I was doing previously.
I understand that there are several other ways to get to the desired result; I've implemented one of them already. However, I am wondering if anyone else is experiencing the inability to dynamically set the "map_id Expression" value in the ApplyMap function since their upgrade to Qlik Sense 3.0 or 3.0.1. I'd like to report this as a potential bug if so.
Thanks,
Justin
Did you happen to miss the variable within the ApplyMap?
// **** Number of phase weights ****
Let vTemp = Trim(Replace(FieldName(NoOfFields('Phases'), 'Phases'), 'Weight ', ''));
// **** Loop through and create weight mappings ****
For i = 1 to $(vTemp)
Weight$(i):
Mapping Load
[Phase],
[Weight $(i)]
Resident [Phases];
Next;
// **** Get Weighted Phase Score ****
Load [Account Name],
[Phase],
Max([Phase Score]) * ApplyMap('Weight$(i)' & Max([Current Phase]), Max([Phase]), Null()) as [Weighted Phase Score],
Resident [Tasks]
Group by [Account Name], [Phase];
Hi Sunny,
Thanks for the input. I'm using the "Max([Current Phase])" piece as the variable as it is different for each account.
// **** Number of phase weights ****
Let vTemp = Trim(Replace(FieldName(NoOfFields('Phases'), 'Phases'), 'Weight ', ''));
// **** Loop through and create weight mappings ****
For i = 1 to $(vTemp)
Weight$(i):
Mapping Load
[Phase],
[Weight $(i)]
Resident [Phases];
Next;
// **** Get Weighted Phase Score ****
Load [Account Name],
[Phase],
Max([Phase Score]) * ApplyMap('Weight' & Max([Current Phase]), Max([Phase]), Null()) as [Weighted Phase Score],
Resident [Tasks]
Group by [Account Name], [Phase];
May be try this, not sure if this will work or not because I have not tested this, but give it a shot
// **** Get Weighted Phase Score ****
LOAD [Account Name],
Phase,
MaxPhaseScore * ApplyMap('Weight' & MaxCurrentPhase, MaxPhase, Null()) as [Weighted Phase Score];
LOAD [Account Name],
[Phase],
Max([Phase Score]) as MaxPhaseScore
Max([Current Phase]) as MaxCurrentPhase
Max(Phase) as MaxPhase
Resident [Tasks]
Group by [Account Name], [Phase];
Hi Sunny,
I gave that a shot (as it wasn't what I implemented as a fix for the issue) but when I try to load the data Qlik freezes at that piece of code and never completes. I have to close out of the app, wait a few minutes, and then come back into the app. If I try to get back into the app right away it shows the circles/bubbles of the load screen for the app and it doesn't ever load the app...
I'm not sure what the issue is with the code that you provided, as it doesn't provide an error. But again, I'm just trying to get some awareness around my original issue. I've already implemented a fix; I just want to get a consensus that it is indeed an issue with Qlik Sense 3.0 and above.
Thanks again,
Justin
If you are able to provide a sample, I might be able to test run this at my end as well.