Forum Discussion
Result difference between dynamic periods
- 4 years ago
You can achieve this with a disconnected table (no relationships). In this example, the table is ComparisonMonth:
FactTable (m/d/yy format):
Data model:
Measures:
Revenue Total = SUM ( FactTable[Revenue] )Revenue Comparison = VAR vComparisonMonth = SELECTEDVALUE ( ComparisonMonth[Month] ) VAR vResult = CALCULATE ( [Revenue Total], DATEADD ( DimDate[Date], vComparisonMonth, MONTH ) ) RETURN vResultRevenue Variance = [Revenue Total] - [Revenue Comparison]Date slicer uses DimDate[Date]. Comparison Month slicer uses ComparisonMonth[Month].
------------------------------------------------------------
- 4 years ago
Yes, you need a disconnected date table. You can create one using a calculated table:
ComparisonDate = DimDateChange the Revenue Comparison measure to the following. The TREATAS function changes the lineage of the disconnected date table (ComparisonDate) to the main date table (DimDate).
Revenue Comparison = CALCULATE ( [Revenue Total], TREATAS ( VALUES ( ComparisonDate[Month Year] ), DimDate[Month Year] ) )Slicer interactions should be enabled.
-------------------------------------------------------------
Hi DataInsights
Thank you for your prompt reply.
I would like only two slicers; the orignal date and comparison date. So, instead of a slicer where I chose -1, -2, -3 etc., I can pick Dec-2021, Jul-2020, Apr-2019. From what I understand, I will need a disconnected date table for this?
Yes, you need a disconnected date table. You can create one using a calculated table:
ComparisonDate = DimDate
Change the Revenue Comparison measure to the following. The TREATAS function changes the lineage of the disconnected date table (ComparisonDate) to the main date table (DimDate).
Revenue Comparison =
CALCULATE (
[Revenue Total],
TREATAS ( VALUES ( ComparisonDate[Month Year] ), DimDate[Month Year] )
)
Slicer interactions should be enabled.
-------------------------------------------------------------