Override axis date for chart with 2 different date fields

Hi,

I am trying to make a chart that shows how many orders were opened and how many were closed per month on the same chart. Orders that have been opened and closed should show twice on the chart. Once in the month they opened & once in the month they closed.

The dataset looks like this, where the open and closed dates exist on the same row. What can I use for the X axis that will have both fields accurately applied per month? If I choose one, then the other date is incorrect. A beastmode of the 2 does not work either.

Any help is greatly appreciated. :)


Answers

  • You can leave the start date as your x-axis, but you need to change how you count your open and closed dates. I would create a beast mode for open and one for closed. They would look like this:

    Open

    CASE WHEN LAST_DAY(startdate) = LAST_DAY(openeddate) THEN 1 ELSE 0 END
    

    Closed

    CASE WHEN LAST_DAY(startdate) = LAST_DAY(closeddate) THEN 1 ELSE 0 END
    

    The LAST_DAY() function is a handy function that will allow you to see if two dates are in the same month because it will change the date to the last day of the month

    You can drag each of the fields into your y-axis and series and choose Sum and you should get the appropriate totals you are looking for.

    Hope this helps.

    **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.
  • AJ2020
    AJ2020 Member

    Hi @MarkSnodgrass ,

    Thank you very much for your reply. It is not responding the way I had hoped. The numbers look further off than before.

    Sorry, but I grabbed a misleading portion of the dataset. The Start date, the Opened date, and the Closed date can be any combination of months. Same month, different months, or even roll over to the next year. And the difference between the start date and the closed date can be more than the 6 months in the chart.

    Instead of using the start date, is there a way to create a "neutral" date between the opened and closed dates?


  • AJ2020
    AJ2020 Member


  • @AJ2020

    Because of how Domo interprets your data on a row by row basis you'd need to have a record for every day (or month depending on how granular you want to get with your data). You can do this in an ETL. MySQL would logically be simpler because you can do conditional joins but MagicETL may be quicker.

    To start you need a date dimension dataset. Domo provides one in the Domo Dimensions connector (calendar.csv).


    MySQL:

    select `Started`, COUNT(cdo.`dt`) as opened, COUNT(cdc.`dt`) as closed
    FROM `my_dataset` ds
    left JOIN `calendar_dates` cdo on cdo.`dt` BETWEEN ds.`Started` and ds.`Opened Date`
    left JOIN `calendar_dates` cdc on cdc.`dt` BETWEEN ds.`Started` and ds.`Closed Date`
    


    MagicETL:

    Gets quite a bit hairy because you need to go a giant cartesian join twice and then do your filtering twice (open date and closed date). I'd recommend trying MySQL first and if you're having issues then move to Magic.

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