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

YTD expression for fiscal Year

Hi,

I am building an expression for YTD for fiscal year .

The fiscal Year starts in April .

=Count({<DateNum={">=$(=num(makedate(Year(CalendarDate)),4))<=$(=num(today()))"}>}  DISTINCT ENQUIRY_ID)

But somehow its returning incorrect results .

I tried debugging it .It is ignoring the first condition.

could anybody point out the issue.

Regards,

Nadeem

7 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I can't see any evident issue with the formula, but I'd recommend to calculate the YTD and other flags in the load script, which will substantially simplify and perhaps speed up your chart expressions.

cheers,

Oleg Troyansky

www.masterssummit.com - take your QlikView skills to the next level!

fashid
Specialist
Specialist
Author

Ok i think i got the issue

ankitaag
Partner - Creator III
Partner - Creator III

Try

=Count({<DateNum={">=$(=vYearStart)<=$(=vYearEnd)"}>}  DISTINCT ENQUIRY_ID)

where vYearStart==Num(YearStart(today(),4))

and vYearEnd==Num(today())

Keep the DateNum format in the script to Num only

ankitaag
Partner - Creator III
Partner - Creator III

You are using DateNum and CalendarDate...are these two different dates?

fashid
Specialist
Specialist
Author

Hi ,

It worked when i used a variable

=Count({<FYear=,DateNum={">=$(=vStartMonth)"}>}  DISTINCT ENQUIRY_ID)

where vstartmonth=num(makedate($(=Year(today())),4))

I still did not get what the issue was with the earlier expression.

I am working on an application which was developed by someone else and i am not sure about doing all this in the load script .

Regards,

Nadeem

fashid
Specialist
Specialist
Author

Nope they are not different dates

Datenum is created from Date Field by using Num(Date),

and CalendarDate field was created from Date field just by renaming Date as CalendarDate in the master calendar

Hence they are all the same.

Regards,

Nadeem

buzzy996
Master II
Master II

can u try this,

SUM({<DateDimensionName = {'>=$(=YearStart(Today())) <= $(=Today())'}>} MeasureName)