Forum Discussion
DAX Help
- 2 years ago
Hi,
For what i understood you need the difference from last day of the month and first day of the month, for each month, for the column [Actual Spending].
So, i created two colums, Month_Year, and Amplitude, it goes like this
Month_Year = MONTH(Plan1[Calendar Date]) & "/" & YEAR(Plan1[Calendar Date])Amplitude = VAR SPENDING_LAST_DAY = CALCULATE( SUM(Plan1[Actual Spending]), FILTER( ALL(Plan1), EARLIER(Plan1[Center-Account]) = Plan1[Center-Account] && EARLIER(Plan1[Month_Year]) = Plan1[Month_Year] && ENDOFMONTH(Plan1[Calendar Date]) = Plan1[Calendar Date] ) ) VAR SPENDING_FIRST_DAY = CALCULATE( SUM(Plan1[Actual Spending]), FILTER( ALL(Plan1), EARLIER(Plan1[Center-Account]) = Plan1[Center-Account] && EARLIER(Plan1[Month_Year]) = Plan1[Month_Year] && STARTOFMONTH(Plan1[Calendar Date]) = Plan1[Calendar Date] ) ) RETURN SPENDING_LAST_DAY-SPENDING_FIRST_DAYThe result
with this column you can do all of the other things like a top 20, and a calendar filter would work in any interval you want.
Theres probably a cleaner way to do it but, i hope that helps.
Hi,
For what i understood you need the difference from last day of the month and first day of the month, for each month, for the column [Actual Spending].
So, i created two colums, Month_Year, and Amplitude, it goes like this
Month_Year = MONTH(Plan1[Calendar Date]) & "/" & YEAR(Plan1[Calendar Date])
Amplitude =
VAR SPENDING_LAST_DAY = CALCULATE(
SUM(Plan1[Actual Spending]),
FILTER(
ALL(Plan1),
EARLIER(Plan1[Center-Account]) = Plan1[Center-Account] && EARLIER(Plan1[Month_Year]) = Plan1[Month_Year] && ENDOFMONTH(Plan1[Calendar Date]) = Plan1[Calendar Date]
)
)
VAR SPENDING_FIRST_DAY = CALCULATE(
SUM(Plan1[Actual Spending]),
FILTER(
ALL(Plan1),
EARLIER(Plan1[Center-Account]) = Plan1[Center-Account] && EARLIER(Plan1[Month_Year]) = Plan1[Month_Year] && STARTOFMONTH(Plan1[Calendar Date]) = Plan1[Calendar Date]
)
)
RETURN SPENDING_LAST_DAY-SPENDING_FIRST_DAY
The result
with this column you can do all of the other things like a top 20, and a calendar filter would work in any interval you want.
Theres probably a cleaner way to do it but, i hope that helps.