use excel power query to graph p6 data

excel power query & p6 go hand-in-hand. around two years ago, i realized that although my role as a project planner was based on my skills in primavera p6, i was spending a significant amount of my day doing repetitive work in excel. i would update my project schedules in p6 and then spend hours getting all the reports ready.

all this changed when i came across excel’s new data transformation tool power query. power query came out as a plug-in for excel 2014 and is now standard in all post 2014 excel products. power query is designed to transform and shape data into a format that can be organized though a pivot table. the reason this technique is so good for primavera p6 users is that primavera p6 is a database system and produces data that is formatted for power query.

the purpose of this tutorial is to show how the primavera p6 report generating feature along with power query can allow you to quickly and accurately export complex data out of primavera p6 and create understandable reports for other project members. i have found this feature very valuable in giving the project team a better understanding of the project plan and creating more confidence my role as a project planner.

this tutorial explains how to use power query for the following scenario: you have been asked to export the resource loading data from p6 into excel to allow a project manager to investigate the resource usage of each work group over time. you are expecting a lot of changes to the schedule and resource curves due to the project deadlines and resource constraints. how do you export the data quickly and accurately to excel every time you get project feedback?

before you do this tutorial, please make sure that your version of excel is more recent than 2014 and has a data tab available in the ribbon at the top.

the tutorial is broken into three parts.

  1. how to export the resource assignments out of primavera p6 into a csv file using the report generating function.
  2. how to use power query in excel to format the csv file into a format that can be used in a pivot table / pivot chart.
  3. how to format the data into a report that a project manager can easily understand.

part one – exporting a csv file from p6

世界杯2022亚洲比赛时间 has covered many ways to export p6 data to excel, but this technique is a bit different. the first step is to set up the report generating option within primavera p6 to generate a csv file that contains the budgeted and budgeted cumulative hours spread over a month interval. this data will be in the same data format that you see when you click the resource assignment screen within primavera p6.

use excel power query to graph p6 data

step 1
add a new report to the report section of primavera p6.
use excel power query to graph p6 data

step 2
using the report generating wizard, make sure to click the time distribution data check mark, then click the activity resource and role assignments item.
use excel power query to graph p6 data - step 2

step 3
the next screen allows you to set the columns, group and sort, and filters that you want applied to the report. for this simple report example, we will only set the columns option. select and add resource name as the only column in the report.
use excel power query to graph p6 data - step 3

step 4
the next screen allows you to set the data that you want to see in the time distributed report. click on time interval fields and select cum budgeted units and budgeted units.
use excel power query to graph p6 data - step 4

step 5
on the timescale option, set the date interval to month.
use excel power query to graph p6 data - step 5

step 6
click run report. to select the format that the report will be exported in, select the ascii text file option and just use the default options that p6 uses. set the location for the text file that p6 will export under output file.
use excel power query to graph p6 data - step 6

step 7
click finish, and you now have a saved report that can be run against any project in primavera p6.


part two – importing a csv file into excel using power query

the next step is to take the csv file and convert it into a table format that can be analyzed using a pivot table or pivot chart. the big advantage to this technique is that in the future, when you export the csv file again, you can simply refresh the excel workbook and the data will be updated.

step 1
the first step is to go to the data tab in excel and click on the get data option.
importing a csv file into excel using power query

step 2
click from text/csv. you will have to go to the folder that you exported the csv file into from p6.

power query will preview the csv file and parse it into a table format. now open power query and use the interface to shape the data into a format that you can use. click edit in order to do this.
importing a csv file into excel using power query step 2

step 3
this is the power query interface. the transformations that you will add are listed on the right-hand side of the screen.

the first transformation that you want to perform is in column 1. the resource names apply to both the cum budgeted row and the budgeted row. the primavera p6 export, however, skips the second row. you need to correct this and display the resource name in both rows.
importing a csv file into excel using power query step 3

step 4
depending on your version of excel, power query may handle the data differently. you want the date row to be in the first row of the table so that you can promote them as table headers later on.

if your table has the dates in row 1, do nothing and skip to step 5.

if row 1 contains empty cells, follow the next step to remove the empty row and position the date rows in the correct place.

click on the remove top rows option, enter 1 into the pop-up box and click ok.
importing a csv file into excel using power query step 4

step 5
now you need to correct the data in column 1. first, you want to remove any spaces around the text in column 1 by using the trim feature. to do this, right click on column 1, go to transform and then click trim.
importing a csv file into excel using power query step 5

step 6
there is still a problem. you want the blank spaces in column 1 to contain null for the next step. to do this, right click on column 1 and select replace values…
importing a csv file into excel using power query step 6

step 7
in the pop-up box, leave the value to find box blank as that represents the empty spaces. in the replace with box type in null and click ok.

the blank cells in column 1 now contain null.
importing a csv file into excel using power query step 7

step 8
now right click on column 1 and select fill and then down. now the resource names in column 1 are correctly tagged to each row.
importing a csv file into excel using power query step 8

step 9
the second transformation is to unpivot the time distributed data into two columns; one column to contain the dates and another column to contain the hour data.

technically you are normalizing the data. primavera p6 displays the data in a way that is easy for humans to read and understand. you want to undo this step and create a very long table that can be used by the pivot table and pivot chart features in excel. both pivoting and unpivoting data are very useful features in power query.

you want to use the data in row 1 as the column headers on the table. double check that the monthly dates for the resource distribution are in row 1. then click the use first row as headers option on the toolbar, as shown below.
importing a csv file into excel using power query step 9

step 10
the header title on column 2 is not what you want. rename it to units by double clicking on the column header and typing in “units”.
importing a csv file into excel using power query step 10

step 11
now for the unpivot step.

this is where you take the time distributed columns and rearrange that data into one single column that can be used in a pivot table.

you want to unpivot the date columns only – columns 3, 4, 5, and onward. you want to preserve columns 1 & 2. in the future, you may extend the schedule and add more date columns.

to allow the query to work in the future, you select the first two columns by holding shift and selecting them. then, right-click and choose unpivot other columns.

this unpivots all the data columns for budgeted units and cumulative units into the format that you need.

importing a csv file into excel using power query step 11

step 12
click on the filter button in the units column. make sure that you only have budgeted and cum budgeted text selected. if you have a null or blank text in this section, uncheck this option as you do not want to include those rows.
importing a csv file into excel using power query step 12

step 13
the date column has been renamed to “attribute” and the data here is categorized as text.

you will want to change this to a date-type field.

you also want the date field to show correctly even if you email the file to another country where the end user has a different date format on their computer.

to do this, you click on the abc-icon to the left of the column title and click using locale…
importing a csv file into excel using power query step 13

step 14
in the drop-down menu, change data type to date and locale to english (united states). you will want to use whatever locale is setup on your computer. click ok.
importing a csv file into excel using power query step 14

step 15
now go to the value column, click on the abc123-icon to the left of the column title and select decimal number.
importing a csv file into excel using power query step 15

step 16
the final step is to rename columns 3 (attribute) and 4 (value) to be date and hours. you do this by double clicking on the column header and typing the correct text.
importing a csv file into excel using power query step 16

step 17
the query is now finished. the resource name issue has been fixed and the date and hours data are unpivoted.
now you want to return the data to your excel worksheet as a table and use the table to create a pivot chart.

click close and load to.. in the top left corner of the screen.
importing a csv file into excel using power query step 17

you want the data returned as a table in a new tab so select the following options.

importing a csv file into excel using power query step 17.1


part 3 – using the data in a pivot chart

you have taken the csv file from primavera p6 and transformed it into a table that can be manipulated by a pivot table or pivot chart.

step 1
now let’s create the pivot table.

highlight the entire table, click on the insert tab and select pivot chart. in the option box, click new worksheet.

using the data in a pivot chart

in order to set up the pivot chart, drag the right columns into the appropriate pivot chart fields.

drag & drop the date column into the axis categories.

drag & drop the units into the legend (series).

drag & drop the hours column into the values section.

when you dropped the date column into the axis(categories) section, excel automatically adds years and quarters to the date data. to get the chart to display in months, click on the plus symbol in the bottom right corner of the chart until you see months on the x-axis.

the pivot chart now contains the budgeted units and cumulative budgeted units for the project. you need to convert the cumulative budgeted units into a line and assign it a secondary axis.
using the data in a pivot chart step 2

in order to format the cum budgeted properly, click on the chart and select change chart type.

using the data in a pivot chart step 3

select the combo option on the left side of the change chart type menu. the budgeted series should be a clustered column and be on the primary axis (secondary axis is not selected). the cum budgeted series should be a line and the secondary axis box should be checked. this will display the budgeted units as column with the quantity on the left-hand side and the cum budgeted units as a line with the quantity on the right-hand side.

using the data in a pivot chart step 4

you’re almost done. you want to give the project manager the ability to click on each engineering discipline and see the budgeted units for each discipline over time. this will allow them to review the plan in detail with their team. luckily, as you are working with a pivot chart, this is no big deal. go to the pivotchart fields section and right click on the resource name line and select add as slicer.
using the data in a pivot chart step 5

the primavera p6 data has been converted into a pivot chart format and the project manager can go through each discipline and review the budgeted units. if there are last-minute changes (there usually are), you simply update primavera p6 and export a new csv file. all the project manager needs to do is refresh and the updated data will be imported and instantly usable.

the image below shows how the slicer can be used to select a resource or a group of 世界杯时间比赛时间 . the hours per month and cumulative hours adjust to each selection, giving the project manager the ability to dig through the data.

using the data in a pivot chart step 6

the final step is to clean up the cumulative budgeted line. when you exported the data from primavera p6 the report included 4 months too much of cumulative data. remove this by clicking on the data tab, selecting queries and connections, opening the query that was just created, and clicking on the drop-down menu at the top of the date column. filter the dates to include dates that are before the 1st of february 2019. then click close and load in the top left corner and the pivot chart will update and display the data correctly. you will have to adjust this filter in the future if the project schedule changes and the 世界杯时间比赛时间 push past the 1st of february.

using the data in a pivot chart step 7

using the data in a pivot chart step 8

using the data in a pivot chart step 9

finally, remember that once the query is set up and you update the csv data source, you will have to update the link between power query and the source file. you do this by selecting refresh all in the data tab.

using the data in a pivot chart step 10

i hope that this tutorial gave you a useful introduction to what power query can do. i have found it to be a valuable tool that drastically helps reduce repetitive tasks and i hope that it can help you out too.

let us know what you think by leaving a comment below.

new call-to-action