3 Replies Latest reply on Apr 21, 2018 9:39 PM by Eva K

# % YTD difference from previous ytd or year-to-month

i have a dataset for the entire year 2016, 2017 and ytd 2018. I am plotting a bar chart for sum(amount) by Year, the user wants the % YTD difference from the previous YTD  or year-to-month in the hover over.

I added a table calc which computes the Percent Difference from previous year, but it's not computing the previous ytd or year-to-month.

I have attached the twbx file.

• ###### 1. Re: % YTD difference from previous ytd or year-to-month

Hi Eva,

Find my approach as reference below and stored in attached workbook version

1. ND1. Date: date(str([Year])+'-'+[Month]+'-'+'1')

2. NM1. YTD: if datediff('year',[Date],today())=0 and month([Date])<=month(today()) then [Amount] END

3. NM2. PYTD: if datediff('year',[Date],today())=1 and month([Date])<=month(dateadd('year',-1,today())) then [Amount] END

4. NM3. Fixed YTD: {fixed:sum([NM1. YTD])}

5. NM4. Fixed PYTD: {fixed:sum([NM2. PYTD ])}

6. NM5. % Difference: (sum([NM3. Fixed YTD])-sum([NM4. Fixed PYTD]))/sum([NM4. Fixed PYTD])

7. Drag all required objects to the indicated locations

Regards,

Norbert

1 of 1 people found this helpful
• ###### 2. Re: % YTD difference from previous ytd or year-to-month

Hi, Eva

Please find my solution attached as well as screenshot of result below

Hope this helps

ZZ

1 of 1 people found this helpful
• ###### 3. Re: % YTD difference from previous ytd or year-to-month

Thank you so much Norbert and Zhouyi,

Norbert, I found Zhouyi's method less complex and hence I marked that answer as Correct, but thank you so much for your help.