# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

New Contributor II

## How to get Number of Days per Month for past six months in bar chart

Hi,

I'm Mun. I'm experimenting to display number of days in a month for past six months range.

For example, when I select June 2017 in the MonthYear filter, the graph will display number of days from January 2017 until June 2017.

Meanwhile, when I select May 2017, the graph should show from December 2016 to May 2017.

At the moment, it doesn't work like that. Currently, if I select June 2017, the graph will only show the value for that particular month.

For the measure, which is number of days in a month, I used this expression:

Sum(Aggr(Day(MonthEnd(Max(DateField))),DateField))

Cheers,

Mun

1 Solution

Accepted Solutions
Esteemed Contributor III

## Re: How to get Number of Days per Month for past six months in bar chart

This works for me:

Chart dimension is [Month Year]

Chart expression is

count({<[Month Year]={"\$(='>=' & date(AddMonths(max([Month Year]),-5),'MMM YY') & '<=' & date(max([Month Year]),'MMM YY'))"}>} distinct DateField)

2 Replies
Highlighted
Valued Contributor III

## Re: How to get Number of Days per Month for past six months in bar chart

First step take the selected date in a variable

try this

Esteemed Contributor III

## Re: How to get Number of Days per Month for past six months in bar chart

This works for me:

Chart dimension is [Month Year]

Chart expression is

count({<[Month Year]={"\$(='>=' & date(AddMonths(max([Month Year]),-5),'MMM YY') & '<=' & date(max([Month Year]),'MMM YY'))"}>} distinct DateField)