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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

YTD month flag based off current month (flag all prior months)

Hello,  I have a regular date table and having a hard time figured out a way to add a column to the data table that simply says "YTD" if the month in the table is less than the current month.  For example, if if the current month were to be June, I would like all the rows for the months of January through May to say "YTD" in the new column.  I need a column that does specifically this for many reasons, so I'd really appreciate this specific solution and not 100 different work arounds.  🙂  Thanks so much in advance!  

 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@Anonymous 

If you only want the flag for the current year:

 

YTD = IF(date table [month] < MONTH(TODAY()) && date table [year] = YEAR(TODAY()), "YTD", BLANK())

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

@Anonymous 

If you only want the flag for the current year:

 

YTD = IF(date table [month] < MONTH(TODAY()) && date table [year] = YEAR(TODAY()), "YTD", BLANK())

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Thanks all!  I feel really stupid.  🙂

Greg_Deckler
Super User
Super User

So, I'm thinking:

 

YTD = 
  IF(
    MONTH([Date]) < MONTH(TODAY()),
    "YTD",
    BLANK()
  )

 

Of cource you did not mention years so not sure if that is an issue or not, but that too would be possible. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_DecklerThanks!  This did exactly what I was looking for...however, I found that our data does not refresh for the prior month until the 4th or 5th business day of the current month.  Therefore, I would now like to adjust the YTD flag formula to take the max period from the current year in my data (instead of month(today)) and use that, so that we're always comparing apples to apples across years.  I hope that makes sense and REALLY appreciate your help!!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.