Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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
vinieme12
Champion III
Champion III

Yep, it works

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

Yaar sample share karde... mein bhi satisfy ho jaunga

Anonymous
Not applicable

Try this

Sum({<Date={">=$(=MonthStart(AddMonths(Max(Date),-6)))<$(=MonthEnd(Max(Date)))"}>}Sales)

vinieme12
Champion III
Champion III

, here you go

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

Cheating bro.... You added NUM#()

Capture.PNG

With Num#() it was always going to work and I guess that was my point

vinieme12
Champion III
Champion III

i forgot to add that

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
nareshthavidishetty
Creator III
Creator III
Author

Hi sunny sorry for the late reply actually i want in calculated dimension

please help me out

vartoday is a variable i defines as 42260

nareshthavidishetty
Creator III
Creator III
Author

Hi vineeth

thanks for the reply but i need it in calculated dimension could you help me out

what will be the expression,vartoday is variable

as im using this now but giving me static it does change whn i select months filter

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

vinieme12
Champion III
Champion III

try below

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

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

I don't think num is needed, but dollar sign expansion of variable might do it.


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

or just use Today() instead of the variable

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