Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator II
Creator II

Dynamic changing as per selection

Hi,

Looking for help in writing an expression. I’ve the below table in my qlik document.

Valueamountdate
A10001/01/2018
A20014/01/2018
A30003/02/2018
A20014/02/2018
A20006/03/2018
A20020/03/2018

now my requirement is when every user selects month in list it has to show current month and previous month value. For example if user select January in month it has to display previous month values as 0 (because there is no previous month) and current month as ‘300’  as below.

Valueprevious month
current month
ANull or 0300

IF the user selects February i want to see the output as below

ValuePrevious monthcurrent month
A300500

Message was edited by: Bharath Vikas Shanagonda  I’m sorry I’ve updated my requirement. Instead of month column I will be using date column

8 Replies
Anil_Babu_Samineni

May be this?

Where month_num created in script using below.

Num(Month(Date#(month,'MMMM'))) as month_num

Then, Create table

Previous Month

Sum({<month,month_num = {"$(=Max(month_num-1))"}>} amount)


Current Month

Sum({<month_num = {"$(=Max(month_num))"}>} amount)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

PFA from Update?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vikasshana
Creator II
Creator II
Author

Just updated the requirement Anil.

vikasshana
Creator II
Creator II
Author

Didn’t have access to qlikview now as I’m using my mobile. Can you put the expression here please.

Anil_Babu_Samineni

Expression is same, Script looks this?

LOAD *, month(Date#(date,'DD/MM/YYYY')) as month,Num(month(Date#(date,'DD/MM/YYYY'))) as month_num Inline [

Value, amount, date

A, 100, 01/01/2018

A, 200, 14/01/2018

A, 300, 03/02/2018

A, 200, 14/02/2018

A, 200, 06/03/2018

A, 200, 20/03/2018

];

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
vikasshana
Creator II
Creator II
Author

thanks for that Anil, it is working fine and i've tested in straight table. Based on the selection it is giving me the result which I'm expecting. I'm giving the label name for an expression manually (current and previous) but I'm looking for an expression to change the label name dynamically.

For example if I select Feb month in the list box instead of previous the label name has to be Jan and for current it has to be Feb.

vikasshana
Creator II
Creator II
Author

stalwar1‌ can you help me on this please.

Anil_Babu_Samineni

You can use Label like

Prev Month

=Date(Max(month)-1,'MMMM')


Current Month

=Date(Max(month),'MMMM')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful