Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhavvibudagam
Creator II
Creator II

How to restrict last 6 Months in Bar chart

Hi Experts,

Can any one please help me on below requirement.

I have a date field like below in DD/MM/YYYY format.

In the Year 2018 I have the Jan to Dec Months Data.

In one bar chart I have to show first 6 months data i.e., from jan to Jun only.

In another bar chart I have to show last 6 months data i.e., from July to Dec.

I have calculated Month Name as

MonthName(Date) as [Month Name]

Please help me to write the expressions for first 6months restriction and Last 6 motnhs restriction.

Thanks in advance.

18 Replies
isingh30
Specialist
Specialist

Try like this -

= only({<Year = {'Jan','Feb','Mar','Apr','May','Jun'}>}Date)

Thank you!

bhavvibudagam
Creator II
Creator II
Author

Hi,

I am looking for last 6 months restriction in my set analysis like below.

=Sum({<YearMonth={">=$(=date(addMonths(Max(YearMonth),-6))) <$(=Max(YearMonth))"}>}Sales)

But due to month issue its not working

Anil_Babu_Samineni

What is the format of YearMonth? I always over think to use only dates instead string of another format

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

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
isingh30
Specialist
Specialist

Can you show some sample of your output?

What you want to show in your chart.

Thank you!

bhavvibudagam
Creator II
Creator II
Author

Hi Anil,

Thanks a lot for your reply. Its working fine. Could you please help me to write first 6 months restriction formula i.e., from jan to Jun.

chinnuchinni
Creator III
Creator III

hi,

if your excluded months are fixed you can directly exclude with below.

sum({<Month -= {1,2,3,4,5,6}>}Sales)

sudhirpkuwar
Partner - Creator II
Partner - Creator II

Hi,

Try this

=Sum({<MonthName={"Jan","Feb","Mar","Apr","May","Jun""}>}Sales)

and

=Sum({<MonthName-={"Jan","Feb","Mar","Apr","May","Jun""}>}Sales)

Anil_Babu_Samineni

May be this?

=Sum({<DateField={">=$(=Min(DateField)) <=$(=AddMonths(Max(DateField),6))"}>}Sales)


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
sudhirpkuwar
Partner - Creator II
Partner - Creator II

Hi Anil,

Min(Date Field) will take the very first date in the records

Slightly changing your expression

=Sum({<DateField={">=$(=YearStart(Max(DateField))) <=$(=AddMonths(YearStart(Max(DateField)),6))"}>}Sales)