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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
raylang1
Partner - Contributor II
Partner - Contributor II

Barchart Question

I would like to have a Barchart default to X number of months but then still allow the user to select dates (years, months ) that will change the chart. I have been reviewing some solutions, and what I found so far is the ability to limit a Barchart to X number of months, but then the selections do not work. 

Is what I am trying possible, or by limiting the Barchart to show X number of months, I take away the ability to have the end-user to select other dates for that chart? 

I did try this in the dimension of the chart. It limits tothe last six months but does not allow for additional date selections.

 =If([AdminDate] >= AddMonths(Today(), -6), [AdminDate])

2 Replies
thi_pham
Creator III
Creator III

I suggest to use Max(Total Date) instead of Today():

If([AdminDate] >= AddMonths(Today(), -6), [AdminDate])

Then, you can always get 6 most recent month from the last day of your selection.

 

You can also replace - 6 on above formular by a variable, and end user can edit the variable by a variable input extension, then it's more flexible to control how many months will be showed. (it is same to define a variable in fixed number limitation of dimension).

 

vunguyenq89
Creator III
Creator III

Hi,

You can use function GetSelectedCount(<dimension>) to see if there is any current selections on fields Year/ Month/ Date. From this result, you can use an IF condition to decide whether to show all dates or default to 6 latest months.

For example, with this expression as a calculated dimension in your bar chart:

=If(GetSelectedCount(AdminDate) > 0, [AdminDate], 
     If([AdminDate] >= AddMonths(AdminDate(), -6), [AdminDate]))
  • If there is a current selection on field AdminDate, it shows all values of AdminDate in the dimension
  • If there is no selection, it defaults to dates of 6 latest months

You can add Year, Month to the expression similarly as needed.

Hope this helps,

Vu Nguyen