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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
CiaraCaryl
Frequent Visitor

PYTD Power Query Formula Help

I'm trying to creat PYTD in Power Query because the typical formula is not working in a calculated column. The data set I am using only has dates for the first day of the quarter, and last day of the quarter for each year, no dates inbetween. This is the formula I am trying to use in power query but its just giving me errors. Anyone got any ideas?

PYTD = if Date.IsInYearToDate([quarter] {Date.AddYears([quarter], -1)})

then [channel_licenses_net_added] else 0

CiaraCaryl_0-1742489235277.png

 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @CiaraCaryl , you haven't specified expected output. What about this one?

 

dufoq3_0-1744199162672.png

let
    Source = Table.FromColumns({List.Transform({3,6,9,12}, each Date.EndOfQuarter(#date(2016,_,1)))}, type table[End of Quarter=date]),
    Ad_Check = Table.AddColumn(Source, "IsInYTD", each Date.IsInYearToDate(#date(Date.Year(DateTime.FixedLocalNow()), Date.Month([End of Quarter]), Date.Day([End of Quarter]))))
in
    Ad_Check

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

5 REPLIES 5
dufoq3
Super User
Super User

Hi @CiaraCaryl , you haven't specified expected output. What about this one?

 

dufoq3_0-1744199162672.png

let
    Source = Table.FromColumns({List.Transform({3,6,9,12}, each Date.EndOfQuarter(#date(2016,_,1)))}, type table[End of Quarter=date]),
    Ad_Check = Table.AddColumn(Source, "IsInYTD", each Date.IsInYearToDate(#date(Date.Year(DateTime.FixedLocalNow()), Date.Month([End of Quarter]), Date.Day([End of Quarter]))))
in
    Ad_Check

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

v-csrikanth
Community Support
Community Support

Hi @CiaraCaryl 
I wanted to follow up since I haven't heard from you in a while. Have you had a chance to try the suggested solutions?
If your issue is resolved, please consider marking the post as solved. However, if you're still facing challenges, feel free to share the details, and we'll be happy to assist you further.
Looking forward to your response!

Best Regards,
Community Support Team _ C Srikanth.

v-csrikanth
Community Support
Community Support

Hi @CiaraCaryl 
Could you please confirm if your issue has been resolved?
If you are still facing any challenges, kindly provide further details, and we will be happy to assist you.

Best Regards,
Community Support Team _ C Srikanth.

ronrsnfld
Super User
Super User

  1. What is the error message? (eg, what do you see if you select the word "error" in the PYTD column?
  2. Please provide some sample data (preferably as text) along with:
    1. The expected result from that data
    2. The logic required to derive the expected result from the presented data
SundarRaj
Solution Supplier
Solution Supplier

Hi @CiaraCaryl , here's a different solution you could look at. I'll attach the images of the output and M code used. Thanks

SundarRaj_0-1742492289798.png

SundarRaj_1-1742492341165.png

 

 

Sundar Rajagopalan

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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