How to make my BeastMode dynamic

Hello DOMO Dojo -


I have a beast mode that deals with dates, I am wondering if there is a way to make the date dynamic


Here's my formula>>>>

(case 

when (`TC: Created Date` >= '10/1/2025'and`TC: Created Date` < '1/1/2026') and (`TC: End Date`>= '7/1/2025'and`TC: End Date`<= '9/30/2025') then 'Q4 2025' 

when (`TC: Created Date` >= '7/1/2025'and`TC: Created Date` < '10/1/2025') and (`TC: End Date`>= '4/1/2025'and`TC: End Date`<= '6/30/2025') then 'Q3 2025' 

when (`TC: Created Date` >= '4/1/2025'and`TC: Created Date` < '7/1/2025') and (`TC: End Date`>= '1/1/2025'and`TC: End Date`<= '3/31/2025') then 'Q2 2025' 

when (`TC: Created Date` >= '1/1/2025'and`TC: Created Date` < '4/1/2025') and (`TC: End Date`>= '10/1/2024'and`TC: End Date`<= '12/31/2024') then 'Q1 2025'

when (`TC: Created Date` >= '10/1/2024'and`TC: Created Date` < '1/1/2025') and (`TC: End Date`>= '7/1/2024'and`TC: End Date`<= '9/30/2024') then 'Q4 2024' 

when (`TC: Created Date` >= '7/1/2024'and`TC: Created Date` < '10/1/2024') and (`TC: End Date`>= '4/1/2024'and`TC: End Date`<= '6/30/2024') then 'Q3 2024' 

when (`TC: Created Date` >= '4/1/2024'and`TC: Created Date` < '7/1/2024') and (`TC: End Date`>= '1/1/2024'and`TC: End Date`<= '3/31/2024') then 'Q2 2024' 

when (`TC: Created Date` >= '1/1/2024'and`TC: Created Date` < '4/1/2024') and (`TC: End Date`>= '10/1/2023'and`TC: End Date`<= '12/31/2023') then 'Q1 2024'

when (`TC: Created Date` >= '10/1/2023'and`TC: Created Date` < '1/1/2024') and (`TC: End Date`>= '7/1/2023'and`TC: End Date`<= '9/30/2023') then 'Q4 2023' 

when (`TC: Created Date` >= '7/1/2023'and`TC: Created Date` < '10/1/2023') and (`TC: End Date`>= '4/1/2023'and`TC: End Date`<= '6/30/2023') then 'Q3 2023' 

when (`TC: Created Date` >= '4/1/2023'and`TC: Created Date` < '7/1/2023') and (`TC: End Date`>= '1/1/2023'and`TC: End Date`<= '3/31/2023') then 'Q2 2023' 

when (`TC: Created Date` >= '1/1/2023'and`TC: Created Date` < '4/1/2023') and (`TC: End Date`>= '10/1/2022'and`TC: End Date`<= '12/31/2022') then 'Q1 2023'  

when (`TC: Created Date` >= '10/1/2022'and`TC: Created Date` < '1/1/2023') and (`TC: End Date`>= '7/1/2022'and`TC: End Date`<= '9/30/2022') then 'Q4 2022' 

when (`TC: Created Date` >= '7/1/2022'and`TC: Created Date` < '10/1/2022') and (`TC: End Date`>= '4/1/2022'and`TC: End Date`<= '6/30/2022') then 'Q3 2022' 

when (`TC: Created Date` >= '4/1/2022'and`TC: Created Date` < '7/1/2022') and (`TC: End Date`>= '1/1/2022'and`TC: End Date`<= '3/31/2022') then 'Q2 2022' 

when (`TC: Created Date` >= '1/1/2022'and`TC: Created Date` < '4/1/2022') and (`TC: End Date`>= '10/1/2021'and`TC: End Date`<= '12/31/2021') then 'Q1 2022'

when (`TC: Created Date` >= '10/1/2021'and`TC: Created Date` < '1/1/2022') and (`TC: End Date`>= '7/1/2021'and`TC: End Date`<= '9/30/2021') then 'Q4 2021' 

when (`TC: Created Date` >= '7/1/2021'and`TC: Created Date` < '10/1/2021') and (`TC: End Date`>= '4/1/2021'and`TC: End Date`<= '6/30/2021') then 'Q3 2021' 

when (`TC: Created Date` >= '4/1/2021'and`TC: Created Date` < '7/1/2021') and (`TC: End Date`>= '1/1/2021'and`TC: End Date`<= '3/31/2021') then 'Q2 2021' 

when (`TC: Created Date` >= '1/1/2021'and`TC: Created Date` < '4/1/2021') and (`TC: End Date`>= '10/1/2020'and`TC: End Date`<= '12/31/2020') then 'Q1 2021' 

when (`TC: Created Date` >= '10/1/2020'and`TC: Created Date` < '1/1/2021') and (`TC: End Date`>= '7/1/2020'and`TC: End Date`<= '9/30/2020') then 'Q4 2020' 

when (`TC: Created Date` >= '7/1/2020'and`TC: Created Date` < '10/1/2020') and (`TC: End Date`>= '4/1/2020'and`TC: End Date`<= '6/30/2020') then 'Q3 2020' 

when (`TC: Created Date` >= '4/1/2020'and`TC: Created Date` < '7/1/2020') and (`TC: End Date`>= '1/1/2020'and`TC: End Date`<= '3/31/2020') then 'Q2 2020' 

when (`TC: Created Date` >= '1/1/2020'and`TC: Created Date` < '4/1/2020') and (`TC: End Date`>= '10/1/2019'and`TC: End Date`<= '12/31/2019') then 'Q1 2020'

when (`TC: Created Date` >= '10/1/2019'and`TC: Created Date` < '1/1/2020') and (`TC: End Date`>= '7/1/2019'and`TC: End Date`<= '9/30/2019') then 'Q4 2019'

when (`TC: Created Date` >= '7/1/2019'and`TC: Created Date` < '10/1/2019') and (`TC: End Date`>= '4/1/2019'and`TC: End Date`<= '6/30/2019') then 'Q3 2019'

else 0

end)


Thank you to anyone who can help!

Tagged:

Comments

  • You can use the QUARTER function and the YEAR function eliminate all of your case statement. You could do this:

    CONCAT('Q',QUARTER(`dt`),' ',YEAR(`dt`))
    


    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Hi @MarkSnodgrass


    Thank you for this.


    but I dont know how it can capture what needs to be captured before it can determine that it is for that quarter.

    for example to be determined as "Q3 2019"

    it needs to be between `TC: Created Date` >= '7/1/2019' and `TC: Created Date` < '10/1/2019'

    and between `TC: End Date`>= '4/1/2019' and `TC: End Date`<= '6/30/2019'

  • Replace my dt field (which was my sample field from my dataset with your actual field name, which looks like it is TC Created Date. Your dates for your quarters follow the built-in logic for the quarter function, which is how it will correctly determine Q1, Q2, Q3, Q4. The Year function will extract the year from your TC Created Date field and the CONCAT function will piece it all together.

    Try replacing the dt field with your field and give it a try.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Hi @MarkSnodgrass


    so, I tried the beastmode you gave and this is the result>>>

    I think it is just labeling it.


    where as with the beastmode I am currently using, I use it to filter and this is what I only get

    so for Q4 2022, those 8 were counted for that because

    the `TC: Created Date` is greater than equal to '10/1/2022' and less than '1/1/2023'

    and the `TC: End Date` greater than or equal to '7/1/2022' and `TC: End Date` less than or qual to '9/30/2022'

  • BenSchein
    BenSchein Domo Product Manager

    @WorldWarHulk have you thought about creating a separate dataset with your date logic and then joining that back to the main table in a view. That is usually how I might approach it. I can provide an example if helpful.

  • BenSchein
    BenSchein Domo Product Manager

    @WorldWarHulk it would depend on your data. but I bet you can link back to the original data.

  • @WorldWarHulk

    My bad. I missed that you are looking at 2 different dates to determine the quarter. It will involve a case statement, it can still be dynamic. This should work for you:

    CASE 
    /*check to see if the end date is in the previous quarter of the same year */
    WHEN QUARTER(`TC: Created Date`) - QUARTER(`TC: End Date`) = 1 AND YEAR(`TC: Created Date`) = YEAR(`TC: End Date`) 
    THEN CONCAT('Q',QUARTER(`TC: Created Date`),' ',YEAR(`TC: Created Date`))
    /* 1st quater to 4th quarter check */
    WHEN QUARTER(`TC: Created Date`) - QUARTER(`TC: End Date`) = -3 AND YEAR(`TC: Created Date`)-1 = YEAR(`TC: End Date`) 
    THEN CONCAT('Q',QUARTER(`TC: Created Date`),' ',YEAR(`TC: Created Date`))
    ELSE 0
    END
    

    The first when handles when the created date is in quarters 2, 3, and 4. The 2nd when statement handles when the created date is in 1st quarter and the end date will be in the 4th quarter of the previous year.

    If it doesn't match on either of those then it returns 0.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • WorldWarHulk
    WorldWarHulk Member
    edited October 2022

    Hi @MarkSnodgrass


    This is it! Thank you so much for this!!!