Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
DTL
Contributor II
Contributor II

Lien "automatique" calendrier Civil VS calendrier Fiscal

Bonjour

Après le rachat de mon entreprise, le calendrier fiscal est passé du 01/01-31/12 au 01/04-31/03.

Les utilisateurs souhaiteraient pouvoir sélectionner soit sur une année civile, soit sur année fiscale.

Dans l'exemple joint en image, j'ai fait une bête formule avec des IF pour définir dans quel calendrier fiscale se trouve une date donnée. J'ai commencé de regarder aussi avec la fonction InYear.

Cette solution ne me satisfait pas vraiment car limitée dans le temps ou oblige à régulièrement revoir le script pour rajouter des tests 8-(

Des idées pour rendre "générique" une fonction indiquant à quel calendrier fiscal appartient une date donnée ?

Merci d'avance pour vos contributions/idées.

1 Solution

Accepted Solutions
Taoufiq_Zarra

Bonjour @DTL ,

Je te propose de passer par MasterCalendar dans ce cas avec l'ajout de l'année fiscal, c'est plus simple et propre.

voilà un exemple de script:

Listedate:

load * inline [
ref,Dateref,commentaire
0,01/03/2020,a
1,01/08/2020,b
2,01/09/2020,c
3,25/12/2020,d
4,15/03/2020,e
5,15/04/2020,f
]
;




Temp:

Load

               min(Date#(Dateref,'DD/MM/YYYY')) as minDate,

               max(Date#(Dateref,'DD/MM/YYYY')) as maxDate

Resident Listedate;


LET vStartDate = Num(YearStart(Peek('minDate', 0, 'Temp'), -1));//depuis ta data tu va récuperer le min et max pour construire le mastercalendar

LET vEndDate = Num(YearEnd(Peek('maxDate', 0, 'Temp')));

DROP Table Temp;


SET vFiscalYearStartMonth = 4;

FiscalCalendar:

left join(Listedate)

LOAD

*,

Dual('Q' & Ceil(FiscalMonth/3), Ceil(FiscalMonth/3)) AS FiscalQuarter, // Fiscal Calendar Quarter

Dual(Text(Date(MonthEnd(Dateref), 'MMM')), FiscalMonth) AS FiscalMonthName; // Fiscal Calendar Month Name

LOAD

*,

Year(Dateref) AS Year, // Standard Calendar Year

Month(Dateref) AS Month, // Standard Calendar Month

Date(MonthEnd(Dateref), 'MMM') AS MonthName,  // Standard Calendar Month Name

Dual('Q' & Ceil(Month(Dateref)/3), Ceil(Month(Dateref)/3)) AS Quarter,  // Standard Calendar Quarter

Mod(Month(Dateref) - $(vFiscalYearStartMonth), 12)+1 AS FiscalMonth,  // Fiscal Calendar Month

YearName(Dateref, 0, $(vFiscalYearStartMonth)) AS FiscalYear;  // Fiscal Calendar Year

LOAD

Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS Dateref,

RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

 

pour l'exemple d'entrée, le output est :

Capture.PNG

tu peux enlever le left join si tu veux garder le calendrier séparément sinon tu affiche le calendrier fiscal des données d'entrées seulement

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

3 Replies
Taoufiq_Zarra

Bonjour @DTL ,

Je te propose de passer par MasterCalendar dans ce cas avec l'ajout de l'année fiscal, c'est plus simple et propre.

voilà un exemple de script:

Listedate:

load * inline [
ref,Dateref,commentaire
0,01/03/2020,a
1,01/08/2020,b
2,01/09/2020,c
3,25/12/2020,d
4,15/03/2020,e
5,15/04/2020,f
]
;




Temp:

Load

               min(Date#(Dateref,'DD/MM/YYYY')) as minDate,

               max(Date#(Dateref,'DD/MM/YYYY')) as maxDate

Resident Listedate;


LET vStartDate = Num(YearStart(Peek('minDate', 0, 'Temp'), -1));//depuis ta data tu va récuperer le min et max pour construire le mastercalendar

LET vEndDate = Num(YearEnd(Peek('maxDate', 0, 'Temp')));

DROP Table Temp;


SET vFiscalYearStartMonth = 4;

FiscalCalendar:

left join(Listedate)

LOAD

*,

Dual('Q' & Ceil(FiscalMonth/3), Ceil(FiscalMonth/3)) AS FiscalQuarter, // Fiscal Calendar Quarter

Dual(Text(Date(MonthEnd(Dateref), 'MMM')), FiscalMonth) AS FiscalMonthName; // Fiscal Calendar Month Name

LOAD

*,

Year(Dateref) AS Year, // Standard Calendar Year

Month(Dateref) AS Month, // Standard Calendar Month

Date(MonthEnd(Dateref), 'MMM') AS MonthName,  // Standard Calendar Month Name

Dual('Q' & Ceil(Month(Dateref)/3), Ceil(Month(Dateref)/3)) AS Quarter,  // Standard Calendar Quarter

Mod(Month(Dateref) - $(vFiscalYearStartMonth), 12)+1 AS FiscalMonth,  // Fiscal Calendar Month

YearName(Dateref, 0, $(vFiscalYearStartMonth)) AS FiscalYear;  // Fiscal Calendar Year

LOAD

Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS Dateref,

RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

 

pour l'exemple d'entrée, le output est :

Capture.PNG

tu peux enlever le left join si tu veux garder le calendrier séparément sinon tu affiche le calendrier fiscal des données d'entrées seulement

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
DTL
Contributor II
Contributor II
Author

Bonjour et merci pour la réactivité

Le champ FiscalYear est exactement ce que je cherchais.

Merci encore

Taoufiq_Zarra

très bien ! bonne chance pour la suite

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉