-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 6:44 AM (in response to omar bensalem )I found a solution.
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 12:23 PM (in response to omar bensalem )stalwar1, can you help please?
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 12:26 PM (in response to omar bensalem )I thought you already found a solution to this?
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 12:47 PM (in response to Sunny Talwar )Yes, but I have found yet another problem in my first expression;
Let me do a recap:
As I already said in the first msg above; I have to count (dossier) for each date_embarquement/plaque only in one carrier :
count({<Code_Ligne={'MAR'}
,Groupe_Complet_Vide={c,C,G}
,Dossier = {"=Count(Aggr((Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>} Dossier)
Now, the problem is that I work with variables to do time based analytics (yearly, monthly etc)
To do so, I have to select a Year, a timeframe and so on :
It all works fine in the present period, BUT in the PREVIOUS one; it does not and I know why:
Here is the situation:
My expression for the previous period :
count({<$(vSetPeriodPrev),Code_Ligne={'MAR'}
,Groupe_Complet_Vide={c,C,G}
,Dossier = {"=Count(Aggr((Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>} Dossier)
Let's assume we selected yearly: the vSetPeriodPrev variable will call the YearlyPrev Variable which is like this:
[Calendar date]=,[Year of date]=,[Month of date]=,
[Year of date]={"$(=max([Year of date])-$1)"}
Now, the problem is : In my expression, for the previous period; when I select year of date=2017,
I want my expression to count code_carrier&plaque by date_embarquement in the year 2016 (which is the previous year) !
BUT, when I select 2017 : with the Qlik Associativity, ONLY the date_embarquement in the year 2017 will still be seen and thus; I can not perform this part of the expression:
Dossier = {"=Count(Aggr((Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}
Now, if I select 2017 AND 2016 (it will take the max and work with it BUT the date_embarquement of the year 2016 will be available, so my expression will return the right value:
My question is, what do I have to change?
What should I do to force the 'association of qlik ' not to work?
To force the date_embarquement in 2016 to be available even if I select year of date 2017?
Hope that was rather clear..
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 2:40 PM (in response to omar bensalem )To break the associativity, you need to use set analysis in your inner expression as well... not sure what that would be, but we can start with
count({<$(vSetPeriodPrev),Code_Ligne={'MAR'}
,Groupe_Complet_Vide={c,C,G}
,Dossier = {"=Count({<$(vSetPeriodPrev)>}Aggr((Only($(vSetPeriodPrev)Code_Carrier&Plaque)),Date_Embarquement,Plaque))=1"}>} Dossier)
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 2:48 PM (in response to Sunny Talwar )That didn't display anything
I copied the expression as it is, think there is a wrong syntax ?
here is the original:
count({<$(vSetPeriodPrev),Code_Ligne={'MAR'},Groupe_Complet_Vide={V},
Dossier={"=Count(Aggr((Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>}Dossier)
and the new:
count({<$(vSetPeriodPrev),Code_Ligne={'MAR'}
,Groupe_Complet_Vide={c,C,G}
,Dossier = {"=Count({<$(vSetPeriodPrev)>}Aggr((Only($(vSetPeriodPrev)Code_Carrier&Plaque)),Date_Embarquement,Plaque))=1"}>} Dossier)
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 2:51 PM (in response to omar bensalem )My bad, forgot curly brackets and <>
count({<$(vSetPeriodPrev),Code_Ligne={'MAR'}
,Groupe_Complet_Vide={c,C,G}
,Dossier = {"=Count({<$(vSetPeriodPrev)>}Aggr((Only({<$(vSetPeriodPrev)>} Code_Carrier&Plaque)),Date_Embarquement,Plaque))=1"}>} Dossier)
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 2:54 PM (in response to Sunny Talwar )Same thing; no result yet..
Sorry to keep relying on you to correct my expression !
It's getting too complicated
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 2:58 PM (in response to omar bensalem )Can you share you app, without rar-ing it
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 3:03 PM (in response to Sunny Talwar )Done (first page, last KPI (right)
-
Suivi des remorque-PUN2.qvf 822.5 K
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 3:11 PM (in response to omar bensalem )-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 3:13 PM (in response to Sunny Talwar )Extensions:
the one on the right are buttons;
the one up left is list (you can convert it to filter object and then select a timeframe)
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 3:17 PM (in response to omar bensalem )What is the field name? I don't think I can change the object type. I will recreate the filter object
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 3:20 PM (in response to Sunny Talwar )Timeframe
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 3:39 PM (in response to omar bensalem )Changed your variable to this (Basically remove the double quotes around the Max(Year of date)... part)
[Calendar date]=,[Month of date]=,[Year of date]={$(=max([Year of date])-$1)}
and then this expression
Count({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {c,C,G},
Dossier = {"=Count({<$(vSetPeriodPrev)>}Aggr(Only({<$(vSetPeriodPrev)>} Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>} Dossier)
-
Suivi des remorque-PUN2.qvf 822.5 K
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 3:49 PM (in response to Sunny Talwar )That worked like a charm but why !
I really can't figure out the use of the " " when I work with an aggr function in set analysis !
Sometimes, it only works with double quotes; especially in the case of x= {">=sthing <=sthingelse" }
In this case it works for me only if I surround it with double quotes
But it's the contrary thing in our case !
It's really confusing !!
Well, thank you very mich sunny !
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 3:54 PM (in response to omar bensalem )The problem is that you have double quotes surrounding double quotes
If I expand your variable within your expression... it will look like this
Count({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {c,C,G}, Dossier = {"=Count({<[Calendar date]=,[Month of date]=,[Year of date]={"$(=max([Year of date])-$1)"}>} Aggr(Only({<[Calendar date]=, [Month of date]=, [Year of date] = {"$(=max([Year of date])-$"}>} Code_Carrier&Plaque), Date_Embarquement,Plaque)) = 1"}>} Dossier)
Now this is confusing for QlikView to understand... you can use Escape sequences to handle this, but in your case, since you were doing a set analysis on number, removing double quotes also worked.... but if in case you cannot remove them, then you will have to either use Escape sequence or another technique to handle this
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 4:02 PM (in response to Sunny Talwar )I understand !
Now can you please explain to me :
Count({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {c,C,G},
Dossier = {"=Count({<$(vSetPeriodPrev)>}Aggr(Only({<$(vSetPeriodPrev)>} Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>} Dossier)
why It has to be 2 calls of the vSetPeriodPrev?What does every one do?
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 17, 2017 4:29 AM (in response to omar bensalem )Since you are ignoring selections, and setting your own date range, you have to do that within the inner and outer aggr() functions. That's all it is doing here.... I don't know what else to say
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 16, 2017 2:35 PM (in response to omar bensalem )-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 16, 2017 2:36 PM (in response to omar bensalem )Sorry, got busy with something else... checking now
-
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 17, 2017 4:36 AM (in response to omar bensalem )Hi stalwar1,
I've found yet another 'problem'
In our expression, this what we're doing:
pres:
count({<$(vSetPeriodPres),Code_Ligne={'MAR'},Groupe_Complet_Vide={V},
Dossier={"=Count(Aggr((Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>}Dossier)
prev:
Count({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {V},
Dossier = {"=Count({<$(vSetPeriodPrev)>}Aggr(Only({<$(vSetPeriodPrev)>} Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>} Dossier)
Like this: pres 2016 = prev 2017 (which is the correct thing)
Now, if we change our 2 expressions and instead work with :
Groupe_Complet_Vide={c,C,G}
we'll find differences btwn pres 2016 and prev 2017 (for example)
Can you please see it with me?
Thanks
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 17, 2017 4:42 AM (in response to omar bensalem )I am not sure I understand brother... can you point out by showing images?
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 17, 2017 5:02 AM (in response to Sunny Talwar )See: when I choose 2016, the prev expression (with group)={c,C,G} :
Now, when I choose 2015, the pres expression should be 580; but it's 585 :
As I said, this problem occurs when in my expressions I work with :
Groupe_Complet_Vide={c,C,G}
When I work with Groupe_Complet_Vide={V}, I don't have this problemps: I already changed my script as follow:
Maroc:
LOAD
"%Date ID",
Code_Activite,
Designation_Activite,
Date_Embarquement,
Plaque,
....
Remorque_Parc_HorsParc,
Voyage_Ligne,
Pays,
PAYS2,
Charge_Vide
FROM [lib://qvd/final_16-03-017.qvd]
(qvd)
Where Code_Ligne = 'MAR'
;
Left Join(Maroc)
LOAD
Date_Embarquement,
Plaque,
Only(Code_Carrier) as code
FROM [lib://qvd/final_16-03-017.qvd]
(qvd)
Where Code_Ligne = 'MAR'
Group by Date_Embarquement,Plaque
;
Concatenate
NoMaroc:
LOAD
"%Date ID",
Code_Activite,
Designation_Activite,
Sens,
Filiale_Creation_Dossier,
...
Remorque_Parc_HorsParc,
Voyage_Ligne,
Pays,
PAYS2,
Charge_Vide
FROM [lib://qvd/final_16-03-017.qvd]
(qvd)
Where Code_Ligne <> 'MAR'
;
And my expression is now becoming really simple : count({<$(vSetPeriodPrev),Code_Carrier={'MAR'}>}Dossier)
But, I'm just curious to know why is there a problem with the Groupe_Complet_Vide={c,C,G}
You can see it since you ahev the app in hand
Hope that was rather clear?
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 17, 2017 5:08 AM (in response to omar bensalem )Not completely understand your data well enough to say much (unless I decide to dig deep into it ), but can you check if this makes any difference
Count({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {c,C,G},
Dossier = {"=Count({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {c,C,G}>}Aggr(Only({<$(vSetPeriodPrev), Code_Ligne={'MAR'}, Groupe_Complet_Vide = {c,C,G}>} Code_Carrier&Plaque),Date_Embarquement,Plaque))=1"}>} Dossier)
If this doesn't do anything, I will check your app at a later point and see what might be causing it (digging deeper part)
Best,
Sunny
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 17, 2017 6:32 AM (in response to Sunny Talwar )No, that didn't change a thing
The prev value is always wrong; as if it's deleting the rows where there is dossier (by date and plaque) existing in 2 different carriers.
Pres value for C,G is right; the prev is not..
Even in the script
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 17, 2017 6:56 AM (in response to omar bensalem )So script solution isn't working as well?
-
Re: Transform a set expression to an expression in the script
omar bensalem Mar 17, 2017 7:04 AM (in response to Sunny Talwar )Same result; there is always a problem with C,G: in fact it's deleting the dossier that is duplicated in 2 code_carrier by date/plaque not counting only one dossier
Have you remarked the difference betwen the pres and prev values in the app?
-
Re: Transform a set expression to an expression in the script
Sunny Talwar Mar 17, 2017 7:05 AM (in response to omar bensalem )Not yet... I will look at it sometime today... but in the mean time can you try to explain in simple English what exactly are you trying to do?
-
-
-
-
-
-
-