Forum Discussion
Calculated column DAX
- 2 years ago
(27/04/23-26/04/24)
pls try
=Var _StartDate = Edate(TODAY(),-12)+1Var _EndDate = TODAY()-1returnIF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)(27/03/24-26/04/24)
pls try
=Var _StartDate = EDATE(TODAY(),-1)+1Var _EndDate = TODAY()-1returnIF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0) - 2 years ago
AnalyticsWizard Thanks for your reply, this worked with some minor tweaks only because I changed my mind on how many months I wanted to see, thanks for explaining it!
- 2 years ago
This works as well, thank you!
To modify your DAX calculations for the "This Year" and "This Month" columns to reflect the periods ending yesterday, you can adjust the variables for start and end dates accordingly. Below are the updated DAX formulas based on your requirements:
For "This Year"
This adjusted formula calculates the period from 27th April of the previous year to 26th April of the current year, as of yesterday (26th April 2024):
This Year =
VAR _EndDate = TODAY() - 1
VAR _StartDate = DATE(YEAR(_EndDate) - 1, MONTH(_EndDate) + 1, DAY(_EndDate))
RETURN
IF('CDCalendar'[CallDate] >= _StartDate && 'CDCalendar'[CallDate] <= _EndDate, 1, 0)Explanation:
- `_EndDate` is set to yesterday's date.
- `_StartDate` is set to the same day and month as `_EndDate` but from the previous year. This setup gives you the time period starting from 27th April of the last year to 26th April of the current year.
For "This Month"
This formula will calculate for the period from the 27th of the previous month to the 26th of the current month, as of yesterday (26th April 2024):
This Month =
VAR _EndDate = TODAY() - 1
VAR _StartDate = DATE(YEAR(_EndDate), MONTH(_EndDate), DAY(_EndDate) + 1) - 1
RETURN
IF('CDCalendar'[CallDate] >= _StartDate && 'CDCalendar'[CallDate] <= _EndDate, 1, 0)
If this post helps, please consider Accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudo 👍
AnalyticsWizard Thanks for your reply, this worked with some minor tweaks only because I changed my mind on how many months I wanted to see, thanks for explaining it!