I've read multiple posts on this error: "SAMEPERIODLASTYEAR expects a contiguous selection when the date column comes from a table on the 1-side of a bidirectional relationship." I am still baffled by my error.
I have a simple measure for calculating fees billed:
Fees Billed = CALCULATE(SUM(FactTable[AmtBilledForSubtype]),FactTable[BillSubtype]="FEE")
I have another measure for YTD Fees:
Fees Billed YTD = TOTALYTD([Fees Billed],Table_BasicCalendarUS[DateKey])
No problems with either of these measures.
Now I want Fees Billed for the same period last year. Here is the troublesome measure:
Fees Billed SPLY = CALCULATE([Fees Billed YTD],SAMEPERIODLASTYEAR(Table_BasicCalendarUS[DateKey]))
The error message suggests that there is a bi-directional relationship at the heart of the problem, but
in my date table, the DateKey column has a one-to-many, single cross-filter relationship to the DateBilled colum in the FactTable.
Solved! Go to Solution.
Ok, I'm thinking it's something to do with the fact that your Fees Billed measure is filtering by BillSubType. So what's happening is that it's coming up with blanks for some of the past year's dates when it's trying to calculate the Fees Billed and it doesn't like it.
For the heck of it, can you try adding +0 to your Fees Billed formula:
Fees Billed = CALCULATE(SUM(FactTable[AmtBilledForSubtype])+0,FactTable[BillSubtype]="FEE")
I know this won't fix the issue necessarily, but it would confirm what's going on.
Are you using any filters or slicers on the date in your report? If so, make sure they are not using the date column out of the fact table, but instead the date column out of the date table.
I was slicing the data on the page so that the DateBilled year included only the last 3 years, but one of the first things that occurred to me was to remove this slicer. Removing it had no effect on the error.