Forum Discussion
Mkrishna
Helper III
2 years agoContext Transitioning not working /Code not working
Hi All, I am new to PBI and this is my data model My goal is to caculate as follows 1. If user select date December 2023 then the code should first find the common store in Fact table ...
- 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.
Mkrishna
Helper III
2 years agoAnonymous plz do help