Forum Discussion
Please Help! Bookmarks issue.
- 3 years ago
Hi Coryanthony
There are different ways to do it. Please find below a starting point. In the end to really help you we need to see your data model with input sample data and expected output incl. your definition of last 6 months. For example to you calculate it on day or month granularity etc.
Time Intelligence | L6M = VAR __ReferenceDate = MAX(Dim_Date[Date]) VAR __StartDate = EDate(__ReferenceDate,-6) + 1 VAR __Table = FILTER(ALL(Dim_Date), [Date] >=__StartDate && [Date]<=__ReferenceDate) VAR __Result = SUMX(__Table,SUM(Fact_Sales[Value])) RETURN __Resultor
Time Intelligence | L6M = var var_ReferenceDate = LASTDATE('Dim Date'[Date]) var var_StartDate = STARTOFMONTH(DATEADD(var_ReferenceDate ,-5,MONTH)) RETURN CALCULATE( SUM(FactSales[Value]), DATESBETWEEN('Dim Date'[Date],var_StartDate,var_ReferenceDate) )Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
Hi Coryanthony
There are different ways to do it. Please find below a starting point. In the end to really help you we need to see your data model with input sample data and expected output incl. your definition of last 6 months. For example to you calculate it on day or month granularity etc.
Time Intelligence | L6M =
VAR __ReferenceDate = MAX(Dim_Date[Date])
VAR __StartDate = EDate(__ReferenceDate,-6) + 1
VAR __Table = FILTER(ALL(Dim_Date), [Date] >=__StartDate && [Date]<=__ReferenceDate)
VAR __Result = SUMX(__Table,SUM(Fact_Sales[Value]))
RETURN
__Result
or
Time Intelligence | L6M =
var var_ReferenceDate = LASTDATE('Dim Date'[Date])
var var_StartDate = STARTOFMONTH(DATEADD(var_ReferenceDate ,-5,MONTH))
RETURN
CALCULATE(
SUM(FactSales[Value]),
DATESBETWEEN('Dim Date'[Date],var_StartDate,var_ReferenceDate)
)
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.