Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
paulwalker
Creator III
Creator III

Need Help?

Hi Community,

Table1:

IDDateSales
1009/1/20142000
1019/2/2014100
1029/7/2014120
1039/4/2014325
1049/5/2014350
1059/6/2014415
1069/17/20149000
1079/18/201412500
1089/9/20148500
1099/1/20135500
1109/2/20133500
1119/7/20137500
1129/4/20138600
1139/5/20132590
1149/6/20136530
1159/17/20132980
1169/18/20132450
1179/9/2013450

Fiscal year dataa.....

Here how to calculate FTD, MTD, and YTD

FTD --> Today sales (suppose 9/18/2014)

MTD---> Current month (Month start to today date 1 to 18)

YTD---> current year..(April to this Today date)

By default i want to show current year data.........

8 Replies
rubenmarin

FTD --> Sum({<Date={'$(=Today())'} Sales)

     or Sum({<Date={'$(=Max(Date))'} Sales)

MTD---> Sum({<Date={'>=$(=MonthStart(Today()))'} Sales)

     or Sum({<Date={'>=$(=MonthStart(Max(Date)))'} Sales)

YTD--->Sum({<Date={'>=$(=YearStart(Today(), 0, 4))'} Sales)

     or Sum({<Date={'>=$(=YearStart(Max(Date), 0 , 4))'} Sales)

Is this what you want?

paulwalker
Creator III
Creator III
Author

Hi Marin,

Is it possible in One Bucket at script level..

rubenmarin

Not sure to understand this 'One Bucket' requirement.

Usually buckets distribute records, one record goes to one bucket, in this case 'today' sales will be in FTD, MTD and YTD, not in only one bucket.

you can create flags at script level:

If(Date=Today(), 1) as FTD,

If(Date>=MonthStart(Today()), 1) as MTD,

If(Date>=YearStart(Today(), 4), 1) as YTD

Then the expression should be something like:

Sum({1<FTD={1}>} Sales)

Sum({1<MTD={1}>} Sales)

Sum({1<YTD={1}>} Sales)

paulwalker
Creator III
Creator III
Author

Hi Marin,

Actually i have data based on this bucket(CTD, MTD and YTD) 

i have 3 different type of buckets based Amount, Cost and UnitPrice..


Here above expressions it showing only current data only..

i want if i am click any year i want to show FTD, MTD and YTD

paulwalker
Creator III
Creator III
Author

Hi All,

PFA,

Here i am using Today(), means --> only current year data..

It's showing 2014 data only..

when i am click 2013 year not reflect to my data.. because of using Today()

Script level

LOAD *, If(Date=Max(Date),  'FTD',

                      If(Date>=MonthStart(Max(Date)), 'MTD',

                            If(Date>=YearStart(Max(Date),0,4), 'YTD'))) as Bucket;

It showing error in Script side..

I want to show data Year wise...(FTD, MTD and YTD)

When i am click 2014 ---> 2014 data

2013---> 2013 data

paulwalker
Creator III
Creator III
Author

please anyone can help me

rubenmarin

Hi Paul,

If I understand it well, i think that's not the correct approach, ie. today is 22/09/2014, today sales should sum in FTD, MTD and YTD, making this with the 'if' clauses will cause today sales to only count for FTD, not MTD or YTD.

I think you should use set analisys, working on expressions like:

FTD --> Sum({<Date={'$(=MakeDate(Max(YearField), Month(Today()), Day(Today()))'} Sales)

I don't know for past years what info you want, if the select 2013, what MTD will be shown? Sales of dic-2013? sales of sep-2013, sales from 01/09/2013 to 22/09/2013?

paulwalker
Creator III
Creator III
Author

Hi Marin,

that's ok, but how to write in script level....