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: 
Prakash004
Contributor
Contributor

Restrict the months in dimension filter

Hi Experts,

Can any one please help me on below requirement.

I've data for 24 months but by default the user wants to see the data for 6 months and for the rest of the months he want's to see it using the filter.

I've s_month as the field.

 

 @sunny_talwar   @anil @Anil_Babu_Samineni @Kushal_Chawda @vaibhavv @anu @Sash 

9 Replies
sonkumamon
Creator
Creator

Let me understand you further - in case of no user selection - you want the present the last 6 month. If the user select one month, you want to present only this month data, or the selected month + previous 5 month prior to it, or just the selected month alone?

Prakash004
Contributor
Contributor
Author

It should be just the selected month alone. 

Prakash004
Contributor
Contributor
Author

Instead of writing the expression in every charts and KPI, is there any other work around? 

sonkumamon
Creator
Creator

You can create a master measure and use it in all the charts an KPIs, thus you would need to write the expression only once.

Prakash004
Contributor
Contributor
Author

Hi Sonkumamon, 

 

Could you please help me to write the expression please.

Let's assume the month field is 's_month' , and filed 'Sales' is the measure.

 

Thanks so much in advance. 

Anil_Babu_Samineni

1) Create bookmark for selected one and it allows by default if you are using latest version in QS

2) Perhaps you can play around Only({<s_month = E(s_month)>}s_month)

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
sonkumamon
Creator
Creator

Hi Prakash,

Lets say you want to calculate the measure only for the selected month, then your expression should be something like this:

Sum({<s_month={$(=Max(s_month)}>} Sales)

Lets say you want to calculate the measure for the last 6 month when there is no selection, your expression should be like:

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

So, if you want to make this expression dynamic (shows the last 6 month if no month is selected, and only the selected month in case of a selection, you should either use this 2 measures and each time hide one of then is concern of the selection, or create one dynamic measure:

Sum({<s_month=If(GetSelectedCount(s_month)=0,{">=AddMonths(Max(s_month),-6)<=Max(s_month)"},Max(s_month)) >} Sales)

Keep in mind that using the above expression may effect the performance as it uses an if expression for in  a measure.

Uri