Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
rajtechnocraft
Creator
Creator

YTD/MTD set analysis calculation required

Hi Community, I just wanted MTD and YTD calculation for sales value and trade date using set analysis Can anyone from experts help me out. Thanks in  advance Regards Raj

3 Replies
SunilChauhan
Champion II
Champion II

YTD:

sum({$<Year = {$(=max(Year ))}, Month= {"<=$(=max({<Year ={$(=max(Year ))}>} Month))"}>} distinct sales)

MTD:

sum({$<Year = {$(=max(Year ))}, Month= {$(=max({<Year ={$(=max(Year ))}>} Month)},Date= {"<=$(=max({<Year ={$(=max(Year ))}>} Date)"}>} distinct sales)

remember month should be in numeric and date in date format or number format

hope this help

Sunil Chauhan
Not applicable

Hi Sunil,

I think you just put it otherwise.

For MTD it should be:

sum({$<Year = {$(=max(Year ))}, Month= {$(=max({<Year ={$(=max(Year ))}>} Month)},Date= {"<=$(=max({<Year ={$(=max(Year ))}>} Month)"}>} sales)

and For YTD it should be :

sum({$<Year = {$(=max(Year ))}, Month= {"<=$(=max({<Year ={$(=max(Year ))}>} Month))"}>} sales)

Regards,

Ashutosh


Not applicable

Hi Raj,

While the above expressions will work but just to make it a little simpller, You can also try this also

YTD:

=sum({$<Year={$(=Max(Year))},Month={"<=$(=max(Month))"}>}Sales)

MTD:

=sum({$<Year={$(=Max(Year))},Month={$(=max(Month))},Date={"<=$(=max(Date))"}>}Sales)

if you want to disregard selections in all other fields then just use 1 in place of $, so the same will be as

YTD:

=sum({1<Year={$(=Max(Year))},Month={"<=$(=max(Month))"}>}Sales)

MTD:

=sum({1<Year={$(=Max(Year))},Month={$(=max(Month))},Date={"<=$(=max(Date))"}>}Sales)

Hope this helps

Regards,

Ashutosh