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

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
Champion

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