Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
JumoGra
Frequent Visitor

Calculated column DAX

Hi There I have two calculated columns that show a 1 value for all dates that fall with a specified time period but I will like to change my calculations slightly to get a slightly different result. Many thanks.

This Year =
Var _StartDate = Date(YEAR(Today()),1,1)
Var _EndDate = TODAY()-1
return
IF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)
I will like the DAX formula to include all dates a year ago as at yesterday, yesterday being (26/04/2024) so I want it to return values for (27/04/23-26/04/24)
The same applies for my this:
This Month =
Var _StartDate = EOMONTH(TODAY(),-1)+1
Var _EndDate = TODAY()-1
return
IF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)
I will like the DAX formula to include all dates a month ago as at yesterday, yesterday being (26/04/2024) so I want it to return values for (27/03/24-26/04/24)
3 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@JumoGra 

 (27/04/23-26/04/24)

pls try 

 

=
Var _StartDate = Edate(TODAY(),-12)+1
Var _EndDate = TODAY()-1
return
IF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)

 

 

(27/03/24-26/04/24)

 

pls try 

 

 

=
Var _StartDate = EDATE(TODAY(),-1)+1
Var _EndDate = TODAY()-1
return
IF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@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!

View solution in original post

This works as well, thank you!

View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@JumoGra 

 (27/04/23-26/04/24)

pls try 

 

=
Var _StartDate = Edate(TODAY(),-12)+1
Var _EndDate = TODAY()-1
return
IF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)

 

 

(27/03/24-26/04/24)

 

pls try 

 

 

=
Var _StartDate = EDATE(TODAY(),-1)+1
Var _EndDate = TODAY()-1
return
IF('CDCalendar'[CallDate]>=_StartDate && 'CDCalendar'[CallDate]<=_EndDate,1,0)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This works as well, thank you!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




AnalyticsWizard
Solution Supplier
Solution Supplier

@JumoGra 

 

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!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.