SAMEPERIODLASTYEAR' only works with contiguous date selections.

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi there,

I have the following DAX Functions and all sems to work well, however when I cross highlight on a specific region, I get the following error:
(PBI Desktop)

Error Message:


MdxScript(Model) (1, 66) Calculation error in measure 'A_MEASURES'[LYTD Value]: Function 'SAMEPERIODLASTYEAR' only works with contiguous date selections.

Below are the DAX functions:

Code:
TYTD Value = TOTALYTD ([Total Value];MAIN_SALES[DATE])
Code:
Total Value = SUM(MAIN_SALES[VALUE])
Code:
TYTD Growth Value = DIVIDE([TYTD Value]-[LYTD Value];[LYTD Value];0))
Code:
TYTD Value = TOTALYTD ([Total Value];MAIN_SALES[DATE])
Code:
LYTD Value = TOTALYTD ([Total value]; SAMEPERIODLASTYEAR( MAIN_SALES[Date]))

I have 3 Charts, Region, Product, Store.
When I click (Cross highlight) one of the items in the Region Chart the Product chart throws out that error, but the strange thing is that the Store chart doesnt.

Any Idea how to get past this?

I have been told to use a Calendar table, however when I change the MAIN_SALES[DATE] to Calendar[DATE] I get completely incorrect results. The Calendar Table has a relationship to the DATE in the MAIN_SALES Table (Date to Date). The MAIN_SALES table does not have alot of dates and there are gaps between the dates. The Calendar table that I created starts from the Year 1990 to 2030.

What I doing wrong?
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
If you created a separate contiguous Calendar table and have it linked to MAIN_SALES[Date] like you note above, are you using columns from the Calendar table in rows/columns/filters/slicers (and not MAIN_SALES[Date])? If so then it should work. As commented before, time intelligence functions in Dax work by sliding the range of dates visible in the current filter context. Because of that many functions require contiguous dates (which is why you are getting an error message). But if using complete Calendar table, you shouldn't get this problem.
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,197
Members
449,214
Latest member
mr_ordinaryboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top