YTD BeastMode with Variables

verytiredgirl
verytiredgirl Member
edited November 26 in Beast Mode

I have 2 variables 'Year Selector' and 'Month Selector' that are being used as filters drop down selection in an App

But also used within a YTD BeastMode:

SUM(CASE
WHEN Year Selector = Fiscal Year
AND Month Number >= 2
AND Month Number <= CASE
WHEN Month Selector = 'January' THEN 1
WHEN Month Selector = 'February' THEN 2
WHEN Month Selector = 'March' THEN 3
WHEN Month Selector = 'April' THEN 4
WHEN Month Selector = 'May' THEN 5
WHEN Month Selector = 'June' THEN 6
WHEN Month Selector = 'July' THEN 7
WHEN Month Selector = 'August' THEN 8
WHEN Month Selector = 'September' THEN 9
WHEN Month Selector = 'October' THEN 10
WHEN Month Selector = 'November' THEN 11
WHEN Month Selector = 'December' THEN 12
ELSE 0
END
THEN IFNULL(Amount * -1, 0)
ELSE 0
END)

The problem with this is my Fiscal Year starts from Feb 2024 - Jan 2025. So with the current BeastMode, YTD for all other months are correct except for January.

Example: with the current BeastMode, Jan 2025 YTD is Feb 2024 - Dec 2024 (which is not correct) instead of Feb 2024 - Jan 2025 (this is correct).

Is there any way I could alter my Beastmode?

Tagged:

Best Answer

  • ArborRose
    ArborRose Coach
    Answer ✓

    What if you change January to 13 instead of 1? That should cause it to treat January as part of your fiscal year Feb 2024 - Jan 2025.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

Answers

  • ArborRose
    ArborRose Coach
    Answer ✓

    What if you change January to 13 instead of 1? That should cause it to treat January as part of your fiscal year Feb 2024 - Jan 2025.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • @ArborRose That could be feasible but with my Year Selector variable, changing Jan to 13 may not work.

    For example: if the Year Selector = 2025 and the Month Selector = January, the calculation would include all months from February to January of the following year (since January is represented by 13).

    Therefore, January 2025 YTD = sum the amounts from February 2025 to January 2026 (which is not correct). It should be Feb 2024 - Jan 2025 instead

  • I don't have an example set up to try this.

    SUM(CASE
    WHEN (
    (Year Selector = Fiscal Year AND Month Number >= 2) -- From February to December of the current fiscal year
    OR
    (Year Selector = Fiscal Year + 1 AND Month Number = 1) -- Include January of the next calendar year
    )
    AND Month Number <=
    CASE
    WHEN Month Selector = 'January' THEN 1 -- Stop at January for Year Selector = Fiscal Year + 1
    WHEN Month Selector = 'February' THEN 2
    WHEN Month Selector = 'March' THEN 3
    WHEN Month Selector = 'April' THEN 4
    WHEN Month Selector = 'May' THEN 5
    WHEN Month Selector = 'June' THEN 6
    WHEN Month Selector = 'July' THEN 7
    WHEN Month Selector = 'August' THEN 8
    WHEN Month Selector = 'September' THEN 9
    WHEN Month Selector = 'October' THEN 10
    WHEN Month Selector = 'November' THEN 11
    WHEN Month Selector = 'December' THEN 12
    END
    THEN IFNULL(Amount * -1, 0)
    ELSE 0
    END)

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • Thank you for the reply! I also do not have the data for January yet so I couldn't test it out.

    But

    (Year Selector = Fiscal Year + 1 AND Month Number = 1) -- Include January of the next calendar year)
    AND Month Number <= CASE
    WHEN Month Selector = 'January' THEN 1


    this YTD would only return January 2025, so maybe changing January to 13 instead of 1 would work?