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: 
nareshthavidishetty
Creator III
Creator III

last 6 months in bar graph

hi all

actually im showing a bar graph with dimension as month for 12 months

but i need to show only 6 months data from the current month as i tried like this

created calculated dimension =If(Month > Month(AddMonths(VarToday, -6)) and Month <= Month(VarToday), Month)

but it is not working as it is showing from Apr to sep even if i select november,december

i cannot do in script part as i need to do in dimension

thanks,

Naresh

38 Replies
nareshthavidishetty
Creator III
Creator III
Author

it says error in the expression when i tried above expression

sunny_talwar

My bad, missed the parenthesis

If(Month > Month(AddMonths($(VarToday), -6)) and Month <= Month($(VarToday)), Month)


If(Month > Month(AddMonths(Today(), -6)) and Month <= Month(Today()), Month)

nareshthavidishetty
Creator III
Creator III
Author

i tried that with parenthesis while i copied from ur expression but no luck

sunny_talwar

How does Month field look like? I mean it's format? is it read as a dual month field or text?

nareshthavidishetty
Creator III
Creator III
Author

text field

sunny_talwar

And is it just like Jan, Feb? Try this:

If(Month(Date#(Month, 'MMM')) > Month(AddMonths($(VarToday), -6)) and Month(Date#(Month, 'MMM')) <= Month($(VarToday)), Month)

If(Month(Date#(Month, 'MMM')) > Month(AddMonths(Today(), -6)) and Month(Date#(Month, 'MMM')) <= Month(Today()), Month)

or fix this in the script:

LOAD Month(Date#(Month, 'MMM')) as Month

nareshthavidishetty
Creator III
Creator III
Author

in my script datefield is linkdate and format is dd-mm-yyyy

thn i changed my cal to

month(linkdate ) as month

sunny_talwar

So it is dual then....

What is VarToday?

nareshthavidishetty
Creator III
Creator III
Author

sorry i used vartoday that is wrong jus dont consider vartoday actually some one developed this script and they used vartoday which is giving as 13-09-2015 when i checkd in text box

please try to give me expression dont consider vartoday ,which shows last 6 months trend as i need it is calculated dimension

sunny_talwar

I would have thought that this would work?

If(Month > Month(AddMonths(Today(), -6)) and Month <= Month(Today(), Month)

what does this show you?