Archive

Posts Tagged ‘PowerPivot’

PowerPivot DAX case: Resouce planning report with selecting a date parameter

May 23rd, 2011 5 comments

I had an interesting question on my ask a questions page, one that I have (or something similar) heard a few times before. So I decided to do make a blog post on how to solve it

Our company tracks changes in the resource planning using a data warehouse. An example would be:

Assignment 1: Ian 8 hours planned for 3-Jun; valid from 1-jan-2011 until 1-feb-2011.
Assignment 1: Ian 6 hours planned for 3-Jun; valid from 2-feb-2011 until 15-feb-2011.
Assignment 1: Ian 7 hours planned for 3-jun; valid from 16-feb-2011 until infinity.

I what to enable our end-user to select any date level (Date, Week, Month, year) and get the current planning for that planned date (3-jun).

First of all I created a table in Excel to represent the data:

Next I create a date table that I can use to select dates at different levels using a slicer:

I did not create a relationship between the two tables because I want to use the values of the date table to search for values in the planning table. So far i have prepared the tables, next is creating the report.

First I created a workbook and a new pivottable with the slicers from the date table and put the employee name on rows:

 

now for the interesting part, on to the DAX formula. We want to use the values from the slicers to determine the date we want to search the planning table on. We can use values(columnname) to get the current value of the slicer and create a date from that on the fly. For example values(‘Date’[year]) will get the current value of years from the slicer. IF you join all 3 together you can create a new Date: Date(values(‘Date’[year]),values(‘Date’[Month]),values(‘Date’[Day]))

Slicers can have multiple values selected at the same time so we need to make sure that only one is selected at the same time, otherwhise we cannot create this date. We can do this with the following formula’s:

=if( countrows(values(‘Date’[year])) = 1 &&countrows(values(‘Date’[Month])) = 1 &&countrows(values(‘Date’[Day])) = 1,

Now on to creating the DAX formula to finding the right values in the planning table:

=if( countrows(values('Date'[year])) = 1
&&
countrows(values('Date'[Month])) = 1
&&
countrows(values('Date'[Day])) = 1,
CALCULATE(sum(Rates[Hours]),
	FILTER(Rates,
	Rates[Startdate] <= Date(values('Date'[year]),values('Date'[Month]),values('Date'[Day]))
	&&
	(Rates[Enddate] >= Date(values('Date'[year]),values('Date'[Month]),values('Date'[Day]))
	|| ISBLANK(Rates[Enddate]))
	)
	)
,Blank()
)

Let’s look at this step by step:

First we want to calculate the sum of Hours.

CALCULATE (sum(Rates[Hours]),

for the rows in the selected date range:

FILTER(Rates,
Rates[Startdate] <= Date(values(‘Date’[year]),values(‘Date’[Month]),values(‘Date’[Day]))
&&
(Rates[Enddate] >= Date(values(‘Date’[year]),values(‘Date’[Month]),values(‘Date’[Day])) || ISBLANK(Rates[Enddate])) )

Filter the Rates table to return only the rows where
the Rates[Startdate] <= the selected date
AND
Rates[Enddate] >=the selected date OR the Rates[Enddate] is empty.

When this formula is used we get the value we wanted based on the slicer we selected:

Make sure you turn the following “Visually indicate items with no data”  for each slicer (right mouse click, slicer settings):

 

Another blog post with a similar question and answer you can find here: http://www.powerpivotblog.nl/get-values-within-a-start-and-end-date-using-powerpivot-dax

 

Crushed by Your Calendar? Use PowerPivot to analyze why !

April 27th, 2011 No comments

Today the Microsoft’s Business Intelligence team released a very cool PowerPivot app that shows you the power of PowerPivot  from a direction you wouldn’t expect:

REDMOND, Wash. — April 27, 2011 — As tools, email and calendars go one of two ways for many people.

“Your calendar can be on top of you, or you can be on top of your calendar,” said Tom Casey, corporate vice president of Microsoft’s Business Platform Division.

To ensure he continues to operate in the latter group, Casey and his executive assistant, Melissa Krohn, are beta testers for a new business intelligence app called Calendar Analytics. The PowerPivot application retrieves meeting and other information from Exchange and presents it in a simple, easy-to-read dashboard they can use to analyze (and sometimes even change) how the executive uses his time compared to his priorities.

In honor of Administrative Professionals’ Day today, Microsoft’s Business Intelligence team is offering the application free along with an informational video to introduce the app.

For Casey and Krohn, the information analysis helps ensure day-to-day work is contributing to larger goals.

“At the end of the day, it’s helping him, and it’s helping me manage his calendar better, and making sure I am scheduling meetings that are going to align with his commitments,” Krohn said.

On a day that most people give administrative professionals flowers, today they can have “the magic of software,” said Bruno Aziza, director of Microsoft’s Business Intelligence.

In an email-and-calendar-driven world, having a tool for everyone from administrative professionals to information workers to executives to analyze how time is spent is invaluable, he said.

“We only have a set amount of hours available throughout the week,” Aziza said, adding that the biggest difference in competitive business environments can be how effectively people use their time.

 

So what happens here, a Excel add-in will download information from your Exchange (or Office 365) into Excel. This information will be uploaded into PowerPivot that feeds the Dashboards:

 

You can download the workbook for free from MS here. Happy Analyzing :)

Categories: PowerPivot Tags: ,

TFS OData Service, load your TFS data into PowerPivot

April 11th, 2011 No comments

Always wanted to play around with the data that is stored inside your TFS server? This has now become much easier. The TFS team have announced a special OData service to be released for the product.

The purpose of this project is to help developers work with data from Team Foundation Server on multiple types of devices (such as smartphones and tablets) and operating systems. OData provides a great solution for this goal, since the existing Team Foundation Server 2010 object model only works for applications developed on the Windows platform. The Team Foundation Server 2010 application tier also exposes a number of web services, but these are not supported interfaces and interaction with these web services directly may have unintended side effects. OData, on the other hand, is accessible from any device and application stack which supports HTTP requests. As such, this OData service interacts with the client object model in the SDK (it does not manipulate any web services directly).

Download the beta: OData Service for Team Foundation Server 2010
Provide feedback on the beta: TFSOData@Microsoft.com

Watch a video about it here.

TFS Odata Service, load your TFS data into PowerPivot
Categories: BI general, PowerPivot Tags: ,

Use PowerPivot DAX to get values within a Start and End date

April 3rd, 2011 1 comment

Again a interesting question on my ask a questions page, keep them coming :)

Luke had a question where he wanted to get a date based calculation:

I have a table of people and a table of project assignments.
The assignments have a person, start date, end date and number of hours per week.

I want to create a pivot that has the date as columns and people as rows, with the total number of assigned hours as values.

I created a table in Excel that recreates this scenario:

Next I created a new table that contains a separate date range:

I loaded both tables  into PowerPivot. Because  I want to get the total number of hours per day I am unable to work with a relationship between the date table and the fact table. I need to create a formula that searches the fact table for those that rows are appropriate for each date value in the pivottable.

=Calculate(
	sum(Project[Hours]),
		FILTER(Project,
				COUNTROWS(FILTER(VALUES(Dates[Dates]),
						Project[startdate] <= Dates[Dates] &&
						Project[enddate] >= Dates[Dates] ))
				> 0)
		)

This measure does the following:
Calculate the sum of project[hours] for those rows in the Project table that has more than 0 rows in the Date table where Project[startdate] < = ‘Date’[Date] and Project[enddate] >= ‘Date’[Date].

The only downside of this query has to iterate through the entire project table for each row in the date table, is if the Project table is huge this might have big performance impact.

 

A second question was to create a project start date to current date sum. Again we need to create a measure to do it:

=if(COUNTROWS(VALUES(Dates[dates])) = 1,
	SUMX(DATESBETWEEN(Dates[dates], FIRSTDATE(Project[StartDate]), VALUES(Dates[dates]))
			, Project[SumPerDayMeasure])
, BLANK())

What happens here is that we want to sum all the values of the measure per day for each day from the beginning of the project to the current day.
Sumx will sum the values of our previous measure for each day between FIRSTDATE(Project[StartDate]) and VALUES(Dates[dates]), being the current day in the context.

Use PowerPivot DAX and Excel to create a sparkline with running total last 12 month

March 30th, 2011 5 comments

Got an interesting question today. The question was about creating sparklines for all the country’s that shows a running total of sales for the last 12 months (Rolling 12 months) based on the year that I select from a slicer. I use the trick I blogged about before to work with sparklines and PowerPivot, I would recommend reading it for some background.

First I want to start by creating the sheet that I want to use as a report. On this sheet I start by creating the slicer that I want to use, In this case Calendaryear:

Next I create a second sheet where I want to collect my data for the sparklines.

Because we want to show the running 12 months per year I would like to use only the months of one year that is the baseline of the running month. So we hook up the slicer from our report to the pivottable in the other sheet. Select the slicer, go to options and click on pivottable connections, here I can select the pivottable from the other sheet to be filtered as well:

Next we want to create a measure that creates our running total:

=if(COUNTROWS(values(DimDate[CalendarYear])) = 1,
			CALCULATE(SUM(FactSales[SalesAmount]),
				DATESBETWEEN(DimDate[Datekey],
					DATEADD(FIRSTDATE(DimDate[Datekey]),-11, MONTH)
					, LASTDATE(DimDate[Datekey])))
			,blank())

What this DAX measure does is first of all check if only one year is selected using:

COUNTROWS(values(DimDate[CalendarYear])) = 1,

If more than one year is selected we return blank(). If only one year is selected we calculate the running total by doing a sum of FactSales[SalesAmount] by creating a date range using DatesBetween.

The start date of the range is determined by getting the first day of the current month (we know this because of the current row context) and then go back 11 months before that:

DATEADD(FIRSTDATE(DimDate[Datekey]),-11, MONTH)

to the last date of the current month:

LASTDATE(DimDate[Datekey])

Using this in combination of calculate the sum will now calculate over the entire date range.

Now we have the data set up we can create the sparklines. First we need to copy the rows and paste them to the report and create the sparklines on the report page, check the previous blog post on how to create the sparklines.

 

I have uploaded the workbook for download here.

 

The Office Show: Attack budgeting with Excel PivotTables

March 29th, 2011 No comments

Check out this great video from the Office team on what Excel and PowerPivot can do for you and your organisation:

The Office Show is in a budget crisis, and the numbers are a mess. Watch how we use Excel PivotTables and the super-powerful PowerPivot add-in to pull in all the data and discover some, um, surprising results. And once we get that figured out, Doug Thomas shows us how to use PowerPoint broadcast to share the information. Want more info on PivotTables? Check out this post on the Excel blog. Coming soon, we’ll have a lot more about PowerPivot.
Doug Kim

You can find the original video here.

Advanced DAX calculation: doing a moving grouped average in PowerPivot

March 21st, 2011 3 comments

I got an excellent question last week on the ask my answers page that brought me new understanding of DAX. So finally a new interesting (I hope) blog post on DAX.

Let’s say I have a set of sales per week of a specific brand:

Now I want to have the average of sales per week (slicable by brand) and compare it to the average of the last 3 weekly totals. I prepare  the pivottable :

Read more…

Categories: PowerPivot Tags: ,

Understanding the US Debt using PowerPivot

February 17th, 2011 2 comments

One of the major subjects that are talked about in the US is finance. One of those topics is the US debt. I got a mail today that someone published a book about the subject:

http://www.understandingtheusdebt.com/

So you think why do I blog about it ? Well he did all his research using PowerPivot (and you can actually download the workbook on the site )!.

A quote from his site:

The information presented in this book comes from public sources. Where possible, the data was pulled directly from the government agency (e.g., the Bureau of Public Debt, the Bureau of Labor Statistics, etc.) responsible for collecting and producing a given data set. The charts and tables were created in Excel 2010. I used a new Excel add-in, called PowerPivot (www.powerpivot.com), to

  • gather and store data from multiple sources
  • create relationships among different data sets
  • define custom calculations (e.g., last non-empty, yearly changes, etc.)
  • analyze the data using Excel PivotTables and PivotCharts

An Excel workbook, which contains much of the data I present in this book, is available below. If you want to dive further into a particular subject area, you’ll need to a copy of Office 2010 Professional (the PowerPivot add-in is free). I plan to post a brief tutorial for those who want to get more familiar with the data modeling and analysis techniques used in the workbook.  In the meantime, take a look at my August 2010 Article in SQL Server Magazine to learn more about PowerPivot (see the author page for a link).

Check out the entire page and the download link here: http://www.understandingtheusdebt.com/technology.aspx

Great example of a self sevice BI :)

Categories: Uncategorized Tags: ,