The NEXTMONTH function returns a table containing a column with the dates corresponding to the month after the current context.
NEXTMONTH(
dates
)
- dates: Column containing dates.
The NEXTMONTH function returns a table.
The dates argument can be a reference to a column containing dates, an expression that returns a table with a single column containing dates, or a boolean expression that defines a table with a single column containing dates.
This function returns the set of dates corresponding to the month that follows the dates involved in the current context. In other words, the set of dates returned by the function is never part of the current context.
If we define two measures returning the first and the last day of the period returned by the NEXTMONTH function for the Date column of the calendar:
VAR __nextMonth = NEXTMONTH('Calendar'[Date])
RETURN
FIRSTDATE(__nextMonth)
VAR __nextMonth = NEXTMONTH('Calendar'[Date])
RETURN
LASTDATE(__nextMonth)
...and we create a table to which we take the mentioned Date field and both measures, the result is the following:
We see how, for each date in the first column, the period defined by the NEXTMONTH function begins on the 1st of the following month and ends on the last day of the following month.
If, given a table with sales, we define the measure:
...calculating the total sales, and the measure:
[Ventas],
NEXTMONTH(DimDate[Datekey])
)
...to calculate the sales of the following month, and we take both measures to a table in which we place days, months and years in the row header, we obtain the following result:
It can be seen how the calculation of the sales of the following month for the days of January coincides with the total sales of the month of February.
If, in the previous scenario, we take years and quarters to the row headers, the result is the following:
In this case, the [Next Month Sales] measure returns the total sales for the month following each quarter. We can confirm this by viewing the sales per month:
Indeed, the calculation of the measure [Sales following month] for the first quarter of 2007 (€276,891,048.16) coincides with the total sales for the month of April.