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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculate month

Hi Experts,

I have  3 fields those are Month, year, period

now i am having the data like this

month     year          period

03           2018          07/2017

03          2018           09/2017

Now i want to calculate the difference between month year and  period how to calculate the difference ?

Thanks in advance

9 Replies
Anil_Babu_Samineni

There is no Measure in your Table? Will you able to share sample

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
Anonymous
Not applicable
Author

NO measure in the table i want to calculate the difference months b/w the period and month year,

sasiparupudi1
Master III
Master III

Try

MakeDate(Year,MOnth,1)-date#(period,'MM/YYYY'),

Anil_Babu_Samineni

Perhaps this?

Date(MonthName(month&year), 'MM/YYYY') - Date(period,'MM/YYYY')

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
MarcoWedel

what is the difference you would expect given your sample data?

boorgura
Specialist
Specialist

This should give you the difference number of months:

((year-1) - right(period, 4))*12 + (month + 12 ) - Left(period, 2)

vishalarote
Partner - Creator II
Partner - Creator II

Try this it works

load *,

Date(Date#(MonthYear,'MM/YYYY'),'MM/YYYY')-Date(Date#(period,'MM/YYYY'),'MM/YYYY') as Difference;

load *,

month&'/'&year as MonthYear Inline [

month,year,period

03,2018,07/2017

03,2018,09/2017

];

Capture.PNG

Anonymous
Not applicable
Author

Hey Vishal,

Nice Explanation.

gireesh1216
Creator III
Creator III

This one correct.