Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
stephaniee
Creator
Creator

Tranche Cout Moyen

Bonjour, 

J'ai créé un champ calculé dans mon script et souhaité y ajoouter des tranches. 

Le champ concerné est "panier_montant"; et lorsque j'intègre une formule liée au tranche mon chargement de script est en échec car le champ n'est pas reconnu. 

La table ci-dessous fonctionne correctement en l'état sauf à l'ajout des tranches. 

Ma_table :
LOAD `Id_Facture`,
`Num_Dossier`,
`Facturation_Code_Libelle`,
`Facturation_Donnee_Valeur`,
sum(Facturation_Donnee_Valeur) as panier_montant,
if (sum(Facturation_Donnee_Valeur)>0, 'OK', 'KO') as panier_statut
Resident suivi_facturations_lignes
Where (`Facturation_Code_Libelle` = 'Garage_Montant_Pieces' or `Facturation_Code_Libelle` = 'Total_HT_MO' or
`Facturation_Code_Libelle` = 'Garage_Montant_Peinture' or `Facturation_Code_Libelle` = 'Garage_Montant_Pieces_Reemploi')
Group By Id_Facture,Num_Dossier,Facturation_Code_Libelle,Facturation_Donnee_Valeur;

 

Mes tranches seraient : 0 - 3000 ; 3001 - 6500 ; 6501 et + ! 

Merci pour votre aide, 

Stéphanie

1 Solution

Accepted Solutions
sgfreak74
Explorer
Explorer

Bonjour Stéphanie,

Tu peux utiliser la fonction IntervalMatch ()

https://help.qlik.com/fr-FR/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptPrefixes...

T_Tranches:
LOAD * INLINE [
Start, End, Tranche
0, 3000, A
3001, 6500, B
6501, 99999, C
];


Inner Join IntervalMatch ( panier_montant )
LOAD Start, End
Resident T_Tranches;

Bon Courage

View solution in original post

3 Replies
sgfreak74
Explorer
Explorer

Bonjour Stéphanie,

Tu peux utiliser la fonction IntervalMatch ()

https://help.qlik.com/fr-FR/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptPrefixes...

T_Tranches:
LOAD * INLINE [
Start, End, Tranche
0, 3000, A
3001, 6500, B
6501, 99999, C
];


Inner Join IntervalMatch ( panier_montant )
LOAD Start, End
Resident T_Tranches;

Bon Courage

stephaniee
Creator
Creator
Author

Merci beaucoup ! Cela fonctionne. 

stephaniee
Creator
Creator
Author

Par contre, j'ai un souci sur l'application de ma tranche sur mon cout moyen. 

Je m'explique : le cout moyen est la somme des 4 postes que j'ai nommé "panier_montant" : 

Ma_table :
LOAD `Id_Facture`,
`Num_Dossier`,
`Facturation_Code_Libelle`,
`Facturation_Donnee_Valeur`,
sum(Facturation_Donnee_Valeur) as panier_montant,
if (sum(Facturation_Donnee_Valeur)>0, 'OK', 'KO') as panier_statut
Resident suivi_facturations_lignes
Where (`Facturation_Code_Libelle` = 'Garage_Montant_Pieces' or `Facturation_Code_Libelle` = 'Total_HT_MO' or
`Facturation_Code_Libelle` = 'Garage_Montant_Peinture' or `Facturation_Code_Libelle` = 'Garage_Montant_Pieces_Reemploi')
Group By Id_Facture,Num_Dossier,Facturation_Code_Libelle,Facturation_Donnee_Valeur;

 

Or, pour certaines factures, la tranche s'applique à la valeur du poste et non du montant du panier_montant. 

Ex. : 

montant piece : 6540 €: tranche B

Montant MO : 300 €: tranche A 

=> Or le montant global est sup à 6 500€ et devrait uniquement etre dans la tranche B. 

Est-ce que vous pouvez m'aider sur le sujet ?