+ Reply to Thread
Results 1 to 12 of 12

Transforming date intervals on a per month basis for pivot table

  1. #1
    Registered User
    Join Date
    09-08-2022
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    11

    Transforming date intervals on a per month basis for pivot table

    I would like to create a pivot table that displays which employee works on which project in which month. For instance, if you look at my sample table, Tom works a total of 2 months, thereof 0.8 in accouting and 1.2 in service. The pivot table is really great for that.

    The challenging part for me is that my raw table contains start and end dates, so date intervals. The pivot table, however, works with full months. So my question is how I can break down the date intervals to the specific months.

    What I have is the raw data (Table 1) and the result that I would like to see (Pivot Table). However, for creating the pivot table, I had to transform my raw data manually into Table 2. So, how can I get from Table 1 to the Pivot Table automatically? I tried to do the transformation with PowerQuery, but that didn't work. Any thoughts? Thanks in advance!!
    Attached Files Attached Files
    Last edited by zits1; 09-08-2022 at 08:52 AM.

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Transforming date intervals on a per month basis for pivot table

    you mean something like this?

    pqt.png

    project.png

  3. #3
    Registered User
    Join Date
    09-08-2022
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: Transforming date intervals on a per month basis for pivot table

    basically yes! how did you do this?

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Transforming date intervals on a per month basis for pivot table

    try

    Please Login or Register  to view this content.
    then pivot from query
    Attached Files Attached Files
    Last edited by sandy666; 09-08-2022 at 11:27 AM. Reason: added file

  5. #5
    Registered User
    Join Date
    09-08-2022
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: Transforming date intervals on a per month basis for pivot table

    First of all, thank you very much! That already helps, but it's not yet exactly what I need. However, I think that the solution is close.

    Please Login or Register  to view this content.
    This step creates exactly two rows per entry. What (I guess) I need is one row per month, so I believe we need a loop that iterates for the number of months that are between the start date and the end date. Then, the column "Monthly Share" should contain the portion of days that fall in this month. For instance, there should only be one line for Lisa with a value of 0.5 for monthly share, because there are only 15 days between the start date and the end date.

    Secondly, but this should be easy to fix, the new column "Monthly Share" needs to be multiplied with the existing column "Project Share", so that the correct value is shown in the pivot table. So in my mind, "Project Share" stands for the percentage that a person is engaged in a project (e.g., 1.0=full time; 0.4=40% of working time); this parameter is given. "Monthly Share" stands for portion of the month that needs to be count (e.g. 0.5 for half a month); this parameter is calculated.
    Last edited by zits1; 09-08-2022 at 02:06 PM.

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Transforming date intervals on a per month basis for pivot table

    You haven't added any formula to Table2 so how do you know what the value calculation is there.
    Even in the post there is no mention of this

    I know you know but I don't know what you know

    Post example file with details and correct calculation (formula or something) how to get proper values not manually inserted
    Last edited by sandy666; 09-08-2022 at 02:27 PM.

  7. #7
    Registered User
    Join Date
    09-08-2022
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: Transforming date intervals on a per month basis for pivot table

    Sorry, that's right. I have now created a sample file that contains all the steps. The ideal for me would be to have a formula that creates the pivot table directly from table 1 (without the steps of table 2, 3 and 4)
    Attached Files Attached Files

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Transforming date intervals on a per month basis for pivot table

    ok, I'll look at this a bit later

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Transforming date intervals on a per month basis for pivot table

    check this one (not optimised)
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-08-2022
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: Transforming date intervals on a per month basis for pivot table

    How did you do the magic? Looks great! How can I reproduce the green table?

  11. #11
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Transforming date intervals on a per month basis for pivot table

    See M-code in Advanced Editor and steps on the right side in Power Query window

    imho you will need nore info about PQ
    https://docs.microsoft.com/en-us/power-query/

  12. #12
    Registered User
    Join Date
    09-08-2022
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: Transforming date intervals on a per month basis for pivot table

    Thank you so much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to show all dates in one column and time intervals + count in a pivot table?
    By cph020283 in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 06-02-2021, 06:37 PM
  2. [SOLVED] transforming a bad list into a table
    By Diogo2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2020, 11:22 AM
  3. [SOLVED] transforming a bad list into a table
    By Diogo2 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-03-2020, 03:23 PM
  4. Replies: 10
    Last Post: 10-31-2019, 11:33 AM
  5. Transforming pivot table back to the source table
    By Frile in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-17-2015, 02:34 AM
  6. Pivot Table - Axis Label Intervals
    By Debbie6262 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-14-2014, 03:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1