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: 
akuttler
Creator
Creator

% increase from last month

Hello,

I have an expression for total payments :

(Sum({<Account={'2000','2001','2002','2003'}>}Trans))*-1

How would I create a measure for % increase in payments from previous month?

I want this to be rolling dates as I load new data every month. So I want...(total for last month-total for current month)/ Total for last month).

1 Solution

Accepted Solutions
sunny_talwar

Do this in the script to create a new field and then use that as your filter.

Date(MonthStart(TransactionDate), 'MMMM YYYY') as MonthYear


and then use this expression

Sum({<Account = {'2000','2001','2002','2003'}, TransactionDate = {"$(='>=' & Date(MonthStart(Max(TransactionDate)), 'MM/DD/YYYY') & '<' & Date(MonthStart(Max(TransactionDate), 1), 'MM/DD/YYYY'))"}, MonthYear>}Trans)/

Sum({<Account = {'2000','2001','2002','2003'}, TransactionDate = {"$(='>=' & Date(MonthStart(Max(TransactionDate), -1), 'MM/DD/YYYY') & '<' & Date(MonthStart(Max(TransactionDate)), 'MM/DD/YYYY'))"}, MonthYear>}Trans) - 1

View solution in original post

26 Replies
sunny_talwar

Is this in a chart where Month or MonthYear is a dimension? If it is, then try this may be

Sum({<Account={'2000','2001','2002','2003'}>}Trans)/Above(Sum({<Account={'2000','2001','2002','2003'}>}Trans)) - 1

akuttler
Creator
Creator
Author

No I want to display it as a KPI at the top of a sheet above other charts. I have a dimension for month year...and I would like it to update with those selections. The date field is called 'TransactionDate'.

sunny_talwar

So, you would want to compare the max(MonthYear) to its previous? or compare today's month to its previous?

akuttler
Creator
Creator
Author

Today's month or max month, to previous month (same year).

But I would also like the option to compare to same month (previous year). Could you do both?

sunny_talwar

You sure can, it will just help to know what date and time related fields do you have and what are there formats

akuttler
Creator
Creator
Author

The date field is 'TransactionDate'  fomat 'mm/dd/yyyy'

sunny_talwar

May be try this

Sum({<Account = {'2000','2001','2002','2003'}, TransactionDate = {"$(='>=' & Date(MonthStart(Max(TransactionDate)), 'MM/DD/YYYY') & '<' & Date(MonthStart(Max(TransactionDate), 1), 'MM/DD/YYYY'))"}>}Trans)/

Above(Sum({<Account = {'2000','2001','2002','2003'}, TransactionDate = {"$(='>=' & Date(MonthStart(Max(TransactionDate), -1), 'MM/DD/YYYY') & '<' & Date(MonthStart(Max(TransactionDate)), 'MM/DD/YYYY'))"}>}Trans)) - 1

akuttler
Creator
Creator
Author

It gives me NULL

sunny_talwar

Would you be able to provide a sample?