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
Giorgi1989
Advocate II
Advocate II

Is Year to Date and Is Year to Previous Month Dax formulae

Dear All,

 

I have a date table, in which I want to add three columns: IsCurrentMonth,IsYTD, and IsYeartoPreviousMonth

 

For current month I have the following DAX formula:

 

IsCurrentMonth =
IF (
YEAR ( 'Date'[Calendar Year/Month Level 01.Key] ) = YEAR ( TODAY () )
&& MONTH ( 'Date'[Calendar Year/Month Level 01.Key] ) = MONTH ( TODAY () ),
"Yes",
"No"
)
 
Could you please advise what would be the easiest way of doing the same thing for YeartoDate and YeartoPreviousMonth?

Many thanks for your invaluable time and help!
2 ACCEPTED SOLUTIONS
ValtteriN
Super User
Super User

Hi,

Here is one example on how to do this if you want to have these columns:

ISYTD =
var _sdate = DATE(YEAR(TODAY()),1,1)
var _edate = TODAY() return
IF(AND('Calendar'[Date]>=_sdate,'Calendar'[Date]<=_edate),1,0)
 
ISYTD_LM =
var _sdate = DATE(YEAR(TODAY()),1,1)
var _edate = DATE(YEAR(TODAY()),MONTH(TODAY())-1,1) return
IF(AND('Calendar'[Date]>=_sdate,'Calendar'[Date]<=_edate),1,0)

By the way, typically you wouldn't need these columns due to functions like DATESYTD() and DATEADD() that you can use as filters in measures.

I hope this helps and if it does consider accepting this as a solution!




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

Proud to be a Super User!




View solution in original post

VahidDM
Super User
Super User

Hi @Giorgi1989 

 

Try these codes:

 

IsYTD =
IF(
YEAR( 'Date'[Calendar Year/Month Level 01.Key] ) = YEAR( TODAY() )
&& 'Date'[Calendar Year/Month Level 01.Key] <= TODAY(),
"Yes",
"No"
)
 
 
 
IsYeartoPreviousMonth =
IF(
YEAR( 'Date'[Calendar Year/Month Level 01.Key] ) = YEAR( TODAY() )
&& 'Date'[Calendar Year/Month Level 01.Key]
<= DATE( YEAR( TODAY() ), MONTH( TODAY() ) - 1, DAY( TODAY() ) ),
"Yes",
"No"
)
 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

View solution in original post

3 REPLIES 3
Giorgi1989
Advocate II
Advocate II

Immensely grateful to both of you. Works well! Accepted as a solution!

VahidDM
Super User
Super User

Hi @Giorgi1989 

 

Try these codes:

 

IsYTD =
IF(
YEAR( 'Date'[Calendar Year/Month Level 01.Key] ) = YEAR( TODAY() )
&& 'Date'[Calendar Year/Month Level 01.Key] <= TODAY(),
"Yes",
"No"
)
 
 
 
IsYeartoPreviousMonth =
IF(
YEAR( 'Date'[Calendar Year/Month Level 01.Key] ) = YEAR( TODAY() )
&& 'Date'[Calendar Year/Month Level 01.Key]
<= DATE( YEAR( TODAY() ), MONTH( TODAY() ) - 1, DAY( TODAY() ) ),
"Yes",
"No"
)
 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

ValtteriN
Super User
Super User

Hi,

Here is one example on how to do this if you want to have these columns:

ISYTD =
var _sdate = DATE(YEAR(TODAY()),1,1)
var _edate = TODAY() return
IF(AND('Calendar'[Date]>=_sdate,'Calendar'[Date]<=_edate),1,0)
 
ISYTD_LM =
var _sdate = DATE(YEAR(TODAY()),1,1)
var _edate = DATE(YEAR(TODAY()),MONTH(TODAY())-1,1) return
IF(AND('Calendar'[Date]>=_sdate,'Calendar'[Date]<=_edate),1,0)

By the way, typically you wouldn't need these columns due to functions like DATESYTD() and DATEADD() that you can use as filters in measures.

I hope this helps and if it does consider accepting this as a solution!




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

Proud to be a Super User!




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.