I'm receiving this error both in a larger data model and a simplified model.
I have two tables in the data model, a 'quantity' table with a date column containing the first date of each month in a year and an associated quantity and a contiguous three-year 'calendar' table that extends a year prior to and after the dates in quantity table.
I have created a relationship between the date column in the quantity table and the data column in the calendar table.
I have also marked the calendar table as a date table.
In a calculated column of the data model I have entered the following formula to retrieve the quantity for the prior month:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;"> =CALCULATE(SUM(quantity[quantity]), DATEADD(calendar[date], -1, MONTH))
</code>I have also tried the PREVIOUSMONTH() equivalent:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;"> =CALCULATE(SUM(quantity[quantity]), PREVIOUSMONTH(calendar[date]))
</code>Both of these calculations, however, only returns blanks.
If I set the DATEADD interval to zero, the calculation will return the same month's quantity as expected.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;"> =CALCULATE(SUM(quantity[quantity]), DATEADD(calendar[date], 0, MONTH))
</code>Thank you in advance for your help here.
I have two tables in the data model, a 'quantity' table with a date column containing the first date of each month in a year and an associated quantity and a contiguous three-year 'calendar' table that extends a year prior to and after the dates in quantity table.
I have created a relationship between the date column in the quantity table and the data column in the calendar table.
I have also marked the calendar table as a date table.
In a calculated column of the data model I have entered the following formula to retrieve the quantity for the prior month:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;"> =CALCULATE(SUM(quantity[quantity]), DATEADD(calendar[date], -1, MONTH))
</code>I have also tried the PREVIOUSMONTH() equivalent:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;"> =CALCULATE(SUM(quantity[quantity]), PREVIOUSMONTH(calendar[date]))
</code>Both of these calculations, however, only returns blanks.
If I set the DATEADD interval to zero, the calculation will return the same month's quantity as expected.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;"> =CALCULATE(SUM(quantity[quantity]), DATEADD(calendar[date], 0, MONTH))
</code>Thank you in advance for your help here.
Last edited: