Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Calculate Number of Days and Months to match Excel output

Astro55
8 - Asteroid

I'm very new to Alteryx and trying to create a workflow. My data set contains start and end dates for various projects. I need to calculate the number of days and the number of months between the beginning and end dates of each project. 


Issue:
I am getting variances between the Excel and Alteryx calculations. While minor, they can add up to a material impact on my calculations. I figured out how to tweak the Alteryx formula for "number of days" to match my Excel output, but I can't figure out how to do the same for number of months.

Questions:

1. Can you please help me figure out how to get my Alteryx calculation to match my Excel calculation/ output? 

2. Is the "unedited" Alteryx calculation more accurate than my Excel calculation?

 

Details:

  1. Formulas used to calculate the number of days per:
    • Excel: End Date - Start Date + 1

    • Alteryx: DateTimeDiff([Project End Date_Out],[Project Start Date_Out],'Days') + 1 
                     (Note: The "+1" is to get the Alteryx output to match Excel)


  2. Formulas used to calculate the number of months per:
    • Excel: DATEDIF(0,*Number of days*,"M")

    • Alteryx: DateTimeDiff([Project End Date_Out],[Project Start Date_Out],'Months') 

 

 

Question.jpg

12 REPLIES 12
binu_acs
21 - Polaris

@Astro55 I calculated the month difference using the formula DATEDIF(date1, date2,'m') in excel I got the same result as Alteryx, seems to be you are adding 1 to the excel formula result and comparing with Alteryx result. Can you check again? The below red color box I added in excel sheet 

 

binuacs_0-1677622541155.png

 

binu_acs
21 - Polaris

@Astro55 Is there any reason why you are using FLOOR() function? 

Astro55
8 - Asteroid

@binu_acs - firstly, thank you SO much for being so responsive!!!

The floor function was suggested by @BRRLL99 . So I tried that to see if it would get me closer to my required solution.

 

To answer your question about the +1... the difference is due to how the DATEDIF formula is being used:

  • The Excel formula in my original workbook: DATEDIF(0,*number of days*,'M')  (i.e., the Excel formula is calculating number of months based on the number of days calculation that I have... which is: End Date - Start date + 1)

  • The Excel formula in the red box section above is: DATEDIF(Start Date, End Date, 'M') (This calculates the number of months between the start and end date, but does not take the start/ end date into account)

I apologize that this is so frustrating and confusing. I'm still super new to Alteryx, and just learning what I can and can't do in Alteryx.

Labels
Top Solution Authors