Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

Previous 'N' Month calculation

Hi,

The requirement is, when I select a particular month say 'March' for an year say '2020', All the previous months must also be displayed say 'Jan','Feb' and 'March'. How could i achieve this?   Please help me out.

Labels (1)
5 Replies
Highlighted
Specialist III
Specialist III

Re: Previous 'N' Month calculation

Where do you want to show? In a Chart?

Highlighted
Contributor
Contributor

Re: Previous 'N' Month calculation

In a bar chart as well as in a table view. Once I select the parameter, I need this to reflect in both the analysis.

Highlighted
Partner
Partner

Re: Previous 'N' Month calculation

You can accomplish this by introducing set analysis into your chart and table expression. 

The set will differ based on how you want the logict to be, but your header states "Previous 'N' months" so try something like this.

Assuming your original expression is SUM([Amount]) and N=4. I also you have four calendar fields Year, Month, Date and YearMonth that you need to ignore in order to get the expression right. With these assumptions an expression could look like this.

Sum({<Year, Month, YearMonth, Date = {">=$(=addmonths(max(Date),-4))<=$(=max(Date))"}>}[Amount])

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Highlighted
Contributor
Contributor

Re: Previous 'N' Month calculation

The expression is not working sir.

 

My  Requirement is , When i select the  Year is 2020  and Month is May in filter pane, the  line chart should display Jan to May.if I select AUG,the line chart should display 'JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG'.

I want to display like this in table and line chart.

Highlighted
Creator II
Creator II

Re: Previous 'N' Month calculation

Hi,

Try

dimension- Month

exprssion-  sum({<month={"<=$(=max(month))"}>}premium)