Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Current week (entire week) last year formula

Posted on by 15,428

Hi

In analysis view if I want to calculate current week for last year what is the formula? I use CW but it only shows one day  which is 2/5/2023. My goal was to use CW-1Y but this does not work. I thought CW should show 1/30/2023..2/5/2023 but it shows 2/5/2023.

Any help will be greatly appreciate it. 

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Current week (entire week) last year formula

    Hi,

    Did you check as per below code? Not sure if it will work for you.

    CALCDATE('<-1Y>',TODAY)..CALCDATE('<CW-1Y>',TODAY)

    Result - 31/01/22..05/02/22

  • MahGah Profile Picture
    MahGah 15,428 on at
    RE: Current week (entire week) last year formula

    Thanks Mr Bruvik

    It is totally understandable. I was hoping that CW or etc works and filter for true current week not the end of the current week. But I believe I was wrong and that was not intention of CW.

    I will look into custom code or see if I can find work around

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Current week (entire week) last year formula

    Yes- what you are trying to do is to combine a date formula and a date filter and that will not work.

    So a date formula field will only let you enter a calc formula. Once you add the .. you indicates that you are working with a filter.

    I don't know if that was understandable.

    So i think you need some custom code to make that work.

  • MahGah Profile Picture
    MahGah 15,428 on at
    RE: Current week (entire week) last year formula

    Thanks Mr Bruvik 

    I tried that and did not work. See below. the only formula that works is  "-CW-1Y..CW-1Y" but I cannot enter this in Inventory Analysis Template since I get the below error 

    "Validation Results: Your entry of '-CW-1Y..CW-1Y' is not an acceptable value for 'Comparison Date Formula'. The date formula '-CW-1Y..CW-1Y' must include plus (+) or minus (-)."

    Or if enter in Period instead of date 

    "Validation Results -CW-1Y..CW-1Y is not a valid Period Formula." 

    Formula 

    pastedimage1675119281487v1.png

    Result 

    pastedimage1675119300804v2.png

    formula 

    pastedimage1675119319850v3.png

    Result 

    pastedimage1675119332139v4.png

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Current week (entire week) last year formula

    What if you try CW-52W, does that make a difference?

    If not we could look at using the week number and find the same week number last year. But that takes some more code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans