cancel
Showing results for
Did you mean:
Member

## Last 10 days stock in a line chart that changes dynamically with the month filter

Hi all,

I have to show a trend chart of last 10 days of stock that should change with selection of the month filter.

For eg: if july is selected then i have to show the last 10 days of july's stock data.

Can this be done?

22 REPLIES 22
Super Contributor

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

I would do something like this,

```Measure =
VAR maxDate = MAX(Calendar[Date])
VAR maxMonth = MONTH(maxDate)
VAR minDate = maxDate -10
Return
CALCULATE(
[Amount],
All(calendar),
Calendar[Date]=<maxDate,
Calendar[Date]=>minDate,
Calendar[Month]=maxMonth
)```
Member

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

Hi @tex628 ,

I'am still not able to show the last 10 days though. The chart shows me all 30 days of the month.

Super Contributor

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

That sounds strange, could you possibly provide a picture of the chart and measure?

Frequent Visitor

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

Hello Payal4;

can you create a calculated column in your date table like this? after that, use this measure as a filter and select "1". it will filter the last 10 days of the month.

`measure= IF((DimDate[DayNumberOfMonth])-(MAX(DimDate[DayNumberOfMonth])-10)>0;1;0)`

Member

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

What calculated column should we used?

Frequent Visitor

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

Hello @payal4

as I mentioned, the formula is:

`Column= IF((DimDate[DayNumberOfMonth])-(MAX(DimDate[DayNumberOfMonth])-10)>0;1;0)`

Best Regards.

Frequent Visitor

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

Hello Payal4,

in addition, to use this formula, you must have a column in your date table that contains day number of the month.

Member

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

I do no have a gregarion calender. Hence, need to calculate the day number of month.

Member

## Re: Last 10 days stock in a line chart that changes dynamically with the month filter

Is there a way to do this without the day number of year as I do not have the usual calender and have 445 calender? I would have to create a column with day number of year that would again require some logic. I have less time to do the same.

Announcements