alteryx Community

# Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

## YTD - Calculate YTD Amount based on month name

6 - Meteoroid

Hi All,

I have data by month as shown in the below screenshot. I need alteryx to calculate YTD based on the months completed in an year. Also the last completed month should be current month. for example if we are in Dec, current month will be Nov and YTD will be Jan-Nov.

Kindly need your help.

Thanks,

David

7 REPLIES 7
17 - Castor

Yes, it is possible.

You can get the current month with help of datetimenow() and then perform the calculation for the previous months.

Let me know if you need to build a solution for the same.

Many thanks

Shanker V

6 - Meteoroid

yes please, that would be of great help.

17 - Castor

Sure, happy to help!!!

Alteryx

@david_shishir attached is an example workflow. This approach converts the the column headings to a date field so that the Current Month and YTD can be properly derived at the time the workflow is run. I hope this is helpful for you!

17 - Castor

Please find the below expected output.

Year to Date (YTD) = [(Current Period Value  Beginning of Period Value)] ÷ Beginning of Period Value)

I have used this formula to create the YTD

Note: The workflow used to achieve the solution is attached which can be downloaded to see how the solution works.

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

Many thanks

Shanker V

6 - Meteoroid

Hi Matthew, Thank you for the solution. Just one issue we need to address is that if we are in Jan of the new year, then the current month should be Dec of the last year and YTD needs to be whole past year. Can you please tweak the workflow to accommodate it so that it would be a fool proof solution.

Alteryx

@david_shishir updating the logic in the Formula tool will accomplish this for you. The attached version has this change. Admittedly, I don't really encourage this type of logic as it's an assumption. My recommendation would be to consider using actual dates in your data set, you can always format them to your liking later in the workflow output.

Labels