Table Transformer - Get cumulative values within time period based on Start-End columns
Asked by Bart Demol:

Hi,

I have a table (Resource - Project - Start - End - FTE, with dummy data attached for SS purposes) where i transform some stuff on to display the attached gantt.

As you can see, my resource Bryan is over allocated between May 2nd and May 9th. It becomes quite messy to get these details when you have 50+ resources that all have 5-6 projects.

Is there a way tho stack this data into 1 bar/line where it would say 100% - 0% - 100% - 150% - 100% for the given time periods? Bonus points for styling 100%+ parts.

In SQL i would try a common table expression but when i use the WITH operator i get the following error.

e.statements\[0\].compile is not a function

I also tried the html macro but i'm getting nowhere for now

![Capture.PNG](/t5/image/serverpage/image-id/185644i8DCA25C1FA5627BB/image-size/large?v=v2&px=999 "Capture.PNG")


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Bart Demol](/t5/user/viewprofilepage/user-id/4779938) ,

Not sure that your original idea is possible due to stacking not only percentages but very different time periods.

As for now I can suggest using the [Gantt Chart](https://docs.stiltsoft.com/display/public/TFAC/Gantt+chart+type?utm_source=atl_community) provided by the Chart from Table macro with the following settings:

![Mon 1-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/185648i54E36D66D3BEFA30/image-size/large?v=v2&px=999 "Mon 1-1.png")

![Mon 1-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/185649i9DA9BE72D94D7FA0/image-size/large?v=v2&px=999 "Mon 1-2.png")

It seems to me that my variant visualizes the percentages better.

And you may also reuse the source table with the help of the [Table Excerpt/Table Excerpt Include](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Excerpt+and+Table+Excerpt+Include+macros?utm_source=atl_community) macros, wrap the reused table into the Table Filter macro to filter the start dates/resources and use the [Pivot Table](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Pivot+Table+macro?utm_source=atl_community) macro on top to list all the percentages in a neat way:

![Mon 1-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/185650i4C1249CAA04DCC7A/image-size/large?v=v2&px=999 "Mon 1-3.png")

comments: author: Katerina Kovriga {Stiltsoft}
body: As for the Stacked Column chart, I can suggest trying the Pivot Table \<- Chart from Table macros sequence to get smth like that:

![Mon 1-4.png](https://community.atlassian.com/t5/image/serverpage/image-id/185651i0ADAE08DF14AD853/image-size/large?v=v2&px=999 "Mon 1-4.png")

![Mon 1-5.png](https://community.atlassian.com/t5/image/serverpage/image-id/185652i905DDAF59DFCA637/image-size/large?v=v2&px=999 "Mon 1-5.png")


author: Bart Demol
body: Hi [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746) ,

I removed the percentages because I didn't like the progress-bar stile of percentages for resource allocation. And created a column myself with the text concatted that I show in the gantt. And indeed the stacking per user and project works, however that is not what i want to achieve as the certain time period is the key factor I want to report. Normally I could do this in pure SQL but it seems that a CTE for some reason doesn't work.


author: Katerina Kovriga {Stiltsoft}
body: Maybe you can give us a result table that you want to achieve from the source one and the current SQL that you are stuck with? Not sure how you want it to look like.

The Table Transformer uses AlaSQL library, maybe our developers will be able to help.


author: Bart Demol
body: okay... that makes sense since it appears that AlaSQL doesn't support partitioning yet which I need in my common table expression to do this.

Below is an example of what I want the result table to look like (Project column is optional but would of course add quite some information to the resourcing)

So basically, time periods that are overlapping should be split up into distinct periods that have a sum of the overlapping FTE values

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/185679i6ED36200E56D784B/image-size/large?v=v2&px=999 "Capture.PNG")


author: Katerina Kovriga {Stiltsoft}
body: Thank you, I'm going to consult with our developers now and get back here, if they come with any suitable solution.


author: Katerina Kovriga {Stiltsoft}
body: [@Bart Demol](/t5/user/viewprofilepage/user-id/4779938) ,

Please can you provide us with your SQL query that you are trying to use and get a mistake?

And I also forgot to mention that you may use the Table Filter macro in combination with the Chart from Table macro and filter the Gantt chart by the specific resources (not to show all of them at once).


author: Bart Demol
body: well my first table is trying to recontruct all the timespans. But AlaSQL can't do over/partition as per the doc.

Maybe the developers see a way out of this via javascript?

with alldates as (select d.\*, ROWNUMBER() over (partition by Resource order by thedate) as seqnum  
from ((select T1.'Resource', T1.'Start' as thedate from T1)  
union all  
(select T1.'Resource', T1.'End' as thedate from T1)  
) d  
),  
datepair as (select d1.Resource, d1.thedate as BeginDate, d2.thedate as EndDate  
from alldates d1 left outer join  
alldates d2  
on d1.seqnum = d2.seqnum - 1 and d1.Resource = d2.Resource  
) dp  
select dp.Resource, dp.BeginDate, dp.EndDate, SUM(T1.FTE)  
from datepair dp join  
T1  
on dp.Resource = T1.'Resource' and  
dp.BeginDate \>= T1.'Start' and  
dp.EndDate \<= T1.'End'  
group by dp.Resource, dp.BeginDate, dp.EndDate  
order by 1, 2, 3![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/185706iE174B799853726EF/image-size/large?v=v2&px=999 "Capture.PNG")


Tags: confluence-server

gantt

server

table-transformer