Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi , I am trying to show only the last 2 years data in qlik sense chart. but some how I am unable to write the expression correctly which I could get from the community.
Currently the expression shows all the year .I tried to change the expression as below.but it gives error. Could anyone help .
{<FY={$(=Max(Journal_Date.FiscalCalendar.FY)),$(=Max(Journal_Date.FiscalCalendar.FY)-1)}>}
@vinieme12 , I have pasted below the fiscal calendar section. but here it is assigned numeric .
Calendar:
DECLARE FIELD DEFINITION TAGGED '$date'
Fields
Year($1) As Year Tagged ('$numeric'),
Dual('Q' & ceil(month($1)/3), ceil(month($1)/3)) As Quarter,
Month($1) as Month Tagged ('$numeric'),
Date(QuarterStart($1),'YYYY' & '-Q' & ceil(month($1)/3)) As [YYYY-Q],
Date(MonthStart($1),'MMM-YYYY') as [MMM-YYYY],
Week($1) as Week Tagged ('$numeric');
FiscalCalendar:
DECLARE FIELD DEFINITION TAGGED '$date'
Fields
Year(AddMonths($1,-3)) As [Fiscal Year] Tagged ('$numeric'),
'FY' & Date(QuarterStart(AddMonths($1,-3)),'YY') As [FY],
Dual('Q' & ceil(month(AddMonths($1,-3))/3), ceil(month(AddMonths($1,-3))/3)) As [Fiscal Quarter],
Month($1) as [Fiscal Month] Tagged ('$numeric'),
Date(QuarterStart(AddMonths($1,-3)),'YYYY' & '-Q' & ceil(month(AddMonths($1,-3))/3)) As [Fiscal YYYY-Q],
'FY' & Date(QuarterStart(AddMonths($1,-3)),'YY' & '-Q' & ceil(month(AddMonths($1,-3))/3)) As [YearQuarter],
Date(MonthStart($1),'MMM-YYYY') as [YearMonth],
Week(AddMonths($1,-3)) as [Fiscal Week] Tagged ('$numeric');
DERIVE FIELDS FROM FIELDS [Journal_Date] USING [Calendar];
DERIVE FIELDS FROM FIELDS [Journal_Date] USING [FiscalCalendar];
and in another page declaration done as
Period:
Load * Inline [
Period, PeriodFieldName
Quarterly, Journal_Date.FiscalCalendar.YearQuarter
Monthly, Journal_Date.FiscalCalendar.YearMonth
Yearly, Journal_Date.FiscalCalendar.FY
];
Variance_table:
Load * Inline [
Variance_field
Surplus/(Deficit)
Income
Expenditure
Grant Income
];
Year(AddMonths($1,-3)) As [Fiscal Year] Tagged ('$numeric'), <<-- This is a NUMERIC field
'FY' & Date(QuarterStart(AddMonths($1,-3)),'YY') As [FY], <<-- This is a TEXT field
You can USE the [FY] as a dimension but cannot use it to do comparisons such as ><= or additions /subtractions as it is text
You need to use the NUMERIC [Fiscal Year] field for that
sum({<[Fiscal Year]={">=$(=Max([Fiscal Year],2)"}>} somemeasure)
or
sum({<[Fiscal Year] ={">=$(=Max([Fiscal Year],2)<=$(=Max([Fiscal Year])"}>} somemeasure)
or
sum({<[Fiscal Year] ={'$(=Max([Fiscal Year],2)','$(=Max([Fiscal Year])'}>} somemeasure)
@vinieme12 thanks again.
have 2 more doubts to clarify.
As you mentioned, I am using the Fiscal Year(numeric) now , in my script , it becomes Journal_Date.FiscalCalendar.Fiscal Year.
sum({<[Journal_Date.FiscalCalendar.Fiscal Year] ={">=$(=Max([Journal_Date.FiscalCalendar.Fiscal Year],2)<=$(=Max([Journal_Date.FiscalCalendar.Fiscal Year])"}>} classification)
The second and third fiscal year used in the expression does not seem to be a field .
The measure used in my case seems to be in a different manner . So I am not sure how to use it inside the expression.I have attached the screenshots below.
Is there any suggestion that you could advise?
just copy paste the below in your current set, i was missing some brackets above
[Journal_Date.FiscalCalendar.Fiscal Year] ={">=$(=Max([Journal_Date.FiscalCalendar.Fiscal Year] ,2))<=$(=Max([Journal_Date.FiscalCalendar.Fiscal Year] ))"}
thanks again for your patience. Why does it show the garbage after expression. If I use the journal.date.fiscalcalendar.fiscal Year alone it works but with the expression , it give error as shown below.
this is working fine, but you need to add in in your current expression!!
example
=sum({<
Classification={'SBU'}
,Account_Code-={'6*','7*','8*'}
,[Journal_Date.FiscalCalendar.Fiscal Year] ={">=$(=Max([Journal_Date.FiscalCalendar.Fiscal Year] ,2))<=$(=Max([Journal_Date.FiscalCalendar.Fiscal Year] ))"}
>}[Deficit Surplus])
@vinieme12 , finally resolved it. thanks again for your help.