Forum Discussion
Context Transitioning not working /Code not working
- Anonymous2 years ago
Hi Mkrishna ,
Then you could try EDATE() function. The function returns the date that is the indicated number of months before or after the start date.
Modified:
Sales Amount = VAR _Reference_Date = MAX ( 'Date'[Date] ) VAR Customers = VALUES ( 'Store List'[Store Number] ) VAR PriorCustomers = CALCULATETABLE ( VALUES ( 'Fact Table'[Store Number] ), FILTER ( ALL ( 'Date' ), 'Date'[Date] >= EDATE ( _Reference_Date, 3 ) && 'Date'[Date] <= _Reference_Date ) ) VAR CommonCustomers = INTERSECT ( Customers, PriorCustomers ) VAR Sales = CALCULATE ( SUM ( 'Fact Table'[Sales] ), FILTER ( ALL ( 'Fact Table' ), 'Fact Table'[Store Number] IN CommonCustomers && 'Fact Table'[Visit Date] >= EDATE ( _Reference_Date, 3 ) && 'Fact Table'[Visit Date] <= _Reference_Date ) ) RETURN SalesBest Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you Anonymous for the reply. I report is montlhy one. I cannot do -90 days as some month will have 31 and some 30 and Feb can have 29/28 days.
Hi Mkrishna ,
Then you could try EDATE() function. The function returns the date that is the indicated number of months before or after the start date.
Modified:
Sales Amount =
VAR _Reference_Date =
MAX ( 'Date'[Date] )
VAR Customers =
VALUES ( 'Store List'[Store Number] )
VAR PriorCustomers =
CALCULATETABLE (
VALUES ( 'Fact Table'[Store Number] ),
FILTER (
ALL ( 'Date' ),
'Date'[Date] >= EDATE ( _Reference_Date, 3 )
&& 'Date'[Date] <= _Reference_Date
)
)
VAR CommonCustomers =
INTERSECT ( Customers, PriorCustomers )
VAR Sales =
CALCULATE (
SUM ( 'Fact Table'[Sales] ),
FILTER (
ALL ( 'Fact Table' ),
'Fact Table'[Store Number]
IN CommonCustomers
&& 'Fact Table'[Visit Date] >= EDATE ( _Reference_Date, 3 )
&& 'Fact Table'[Visit Date] <= _Reference_Date
)
)
RETURN
Sales
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.