<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.adatis.co.uk/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jeremy Kashel&amp;#39;s Blog : Excel, PowerPivot</title><link>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Excel/PowerPivot/default.aspx</link><description>Tags: Excel, PowerPivot</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>PowerPivot Settings for Power View</title><link>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2012/02/20/powerpivot-settings-for-power-view.aspx</link><pubDate>Mon, 20 Feb 2012 16:30:59 GMT</pubDate><guid isPermaLink="false">8d7d37f8-4a66-4c95-9fba-293fa87607dc:10308</guid><dc:creator>Jeremy Kashel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.adatis.co.uk/blogs/jeremykashel/rsscomments.aspx?PostID=10308</wfw:commentRss><comments>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2012/02/20/powerpivot-settings-for-power-view.aspx#comments</comments><description>&lt;p&gt;I’ve been using both PowerPivot and Power View quite a bit recently and, &lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2011/11/29/working-with-images-in-power-view.aspx"&gt;in addition to the post I did a while back&lt;/a&gt;, have made a few further observations on getting the two to play nicely together.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Building an Example PowerPivot Model&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For this post I’ve created a very very simple PowerPivot model, based on the Adventure Works Internet Sales Fact table and its related tables. What this means is that after the model is built, I can build a variety of Excel reports that summarise the measures in the FactInternetSales Adventure Works fact table, such as Sales Amount, Tax Amount or Order Quantity. In the example below I’ve built a very basic report showing Order Quantity by year:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/Excel-report_1CE96495.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Excel report" border="0" alt="Excel report" src="http://blogs.adatis.co.uk/blogs/jeremykashel/Excel-report_thumb_63D28792.png" width="244" height="155" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;On to Power View&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Having already published the workbook to SharePoint, my task now is to create a Power View report, which can be done via the PowerPivot Gallery. If wanted to try and create a visual version of the above report in Power View (E.g. a graph), my steps would be to do first of all drag Calendar Year into the report, then Order Quantity. However, when doing this recently, the result wasn’t quite what I expected:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/Table-Without-Sum_7CCE57D7.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Table Without Sum" border="0" alt="Table Without Sum" src="http://blogs.adatis.co.uk/blogs/jeremykashel/Table-Without-Sum_thumb_67DCD564.png" width="193" height="163" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Order Quantity has not been summed at all, which is the opposite behaviour to that of PowerPivot. Consequently I can’t create a graph visualisation, because Power View thinks I don’t have any measures in my report:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/Greyed-Out-Visualisations_15CA281D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Greyed Out Visualisations" border="0" alt="Greyed Out Visualisations" src="http://blogs.adatis.co.uk/blogs/jeremykashel/Greyed-Out-Visualisations_thumb_43B77AD5.png" width="547" height="137" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Yet if we contrast this to measures such as Internet Sales Amount or Tax Amount, they all work fine. Upon looking at the field list for Internet Sales, we will see that Order Quantity is missing the sum symbol, as Power View has not interpreted it as a measure:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/image_2EC5F862.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/image_thumb_47C1C8A7.png" width="176" height="215" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We can get around this in Power View with a bit of dragging and dropping, but we may as well look why it’s happened in the first place. The reason for this is the way in which the PowerPivot import wizard interprets SQL data types. The OrderQuantity column in the FactInternetSales SQL table has a data type of Smallint, which will not be summarised by default in Power View. Decimal and Money types are fine, hence why Tax Amount and Sales Amount above look ok.&lt;/p&gt;  &lt;p&gt;Rather than changing the data types, we can force Power View to interpret the column as a measure by going to the PowerPivot advanced tab and clicking on Summarize By. If the Summarize By value is changed from Default to Sum, then Power View will interpret the column as a measure:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/image_239C6E18.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/image_thumb_0EAAEBA5.png" width="267" height="231" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If we republish the model and then go back to Power View, we will see quite a difference with the same actions as before. First of all the field list is looking correct: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/Summarize-By-After_3C983E5D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Summarize By After" border="0" alt="Summarize By After" src="http://blogs.adatis.co.uk/blogs/jeremykashel/Summarize-By-After_thumb_27A6BBEA.png" width="175" height="212" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Secondly, only dragging Calendar Year and Order Quantity will now give the following correct results:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/Table-With-Sum-After_6E8FDEE7.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Table With Sum After" border="0" alt="Table With Sum After" src="http://blogs.adatis.co.uk/blogs/jeremykashel/Table-With-Sum-After_thumb_1C7D31A0.png" width="212" height="177" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now that we have a measure, it means that we can now change the table into a visualisation of our choice:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/Visualisations-Enabled_078BAF2D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Visualisations Enabled" border="0" alt="Visualisations Enabled" src="http://blogs.adatis.co.uk/blogs/jeremykashel/Visualisations-Enabled_thumb_357901E5.png" width="429" height="108" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Power View is the kind of product that power users are hopefully going to find intuitive, but we can make things even easier for users by making small changes like this.&lt;/p&gt;&lt;img src="http://blogs.adatis.co.uk/aggbug.aspx?PostID=10308" width="1" height="1"&gt;</description><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Excel/default.aspx">Excel</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/PowerPivot/default.aspx">PowerPivot</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Power+View/default.aspx">Power View</category></item><item><title>Allocations in PowerPivot Using DAX</title><link>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2010/02/27/allocations-in-powerpivot-using-dax.aspx</link><pubDate>Sat, 27 Feb 2010 14:56:56 GMT</pubDate><guid isPermaLink="false">8d7d37f8-4a66-4c95-9fba-293fa87607dc:7569</guid><dc:creator>Jeremy Kashel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.adatis.co.uk/blogs/jeremykashel/rsscomments.aspx?PostID=7569</wfw:commentRss><comments>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2010/02/27/allocations-in-powerpivot-using-dax.aspx#comments</comments><description>&lt;p align="justify"&gt;Although I didn&amp;#39;t mention it, the inspiration for my &lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2010/02/11/dax-closing-balances.aspx"&gt;last post&lt;/a&gt; was the excellent &lt;a href="http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0471748080.html" target="_blank"&gt;MDX Solutions 2nd Edition&lt;/a&gt;. Whilst flicking through the book a while back, I though it would be interesting to see how DAX and PowerPivot could handle the so called &amp;#39;Common Calculations and Selections in MDX&amp;#39;.&lt;/p&gt;  &lt;p align="justify"&gt;This post continues that theme, focusing on one calculation in particular that&amp;#39;s in the aforementioned MDX book, namely &amp;#39;Unweighted Allocations down the Hierarchy&amp;#39;. Essentially this business problem is dealing with allocating data that is entered at a higher level (e.g. Quarter) down to a lower level (e.g. Day). It varies from business to business what the users actually want to see at the day level in this situation. Some expect to see the Quarter amount, some want to see a blank value and then some users want the amount in the quarters allocated down to the day level.&lt;/p&gt;  &lt;p align="justify"&gt;If the expectation is that data should be allocated, then one way of doing the allocation is to use a ratio. In the MDX book, this is achieved by the following MDX:&lt;/p&gt;  &lt;pre class="code"&gt;1.0 / 
&lt;span style="color:blue;"&gt;Descendants&lt;/span&gt;(
            &lt;span style="color:maroon;"&gt;Ancestor&lt;/span&gt;(
                    [Date].[Calendar].&lt;span style="color:maroon;"&gt;CurrentMember&lt;/span&gt;,
                    [Date].[Calendar].[Calendar Quarter]
                    ),
            [Date].[Calendar].&lt;span style="color:maroon;"&gt;CurrentMember&lt;/span&gt;.&lt;span style="color:blue;"&gt;Level&lt;/span&gt;,
            &lt;span style="color:blue;"&gt;SELF
            &lt;/span&gt;).&lt;span style="color:blue;"&gt;Count&lt;/span&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;If we put this into a query and run it against the Calendar hierarchy in AdventureWorksDW we get the following results:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="184" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_thumb_3.png" width="295" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;Therefore our quarter-entered value can simply be multiplied by this ratio to get the correct value at each level in the Calendar hierarchy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PowerPivot&lt;/strong&gt;&lt;/p&gt;

&lt;p align="justify"&gt;So the challenge is how to be able to do this in PowerPivot. I started off by looking for some data in AdventureWorksDW that would fit the bill. A good candidate seems to be the FactSalesQuota table, which I imported into PowerPivot along with its related dimensions:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="267" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_thumb_1.png" width="686" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;Once in the pivot table, I wanted to be able to calculate the correct ratio at the daily and monthly levels. For the daily level this is 1 / 90, as there are 90 days in the Q1 that year, and for the month level it is 1/3 as there are 3 months in the quarter.&lt;/p&gt;

&lt;p align="justify"&gt;Given that there&amp;#39;s no MDX style Ancestor() function in DAX, I ended up having to have a different calculation at different levels. Something that I learnt from &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlkjpowerpivotforexcel/thread/99a73152-bbd5-41f3-88c7-054e8988f395" target="_blank"&gt;this forum post&lt;/a&gt; is that you need to use IF() in order to isolate a calculation at a different level. Therefore the DAX that I came up with was:&lt;/p&gt;

&lt;p&gt;=IF( COUNTROWS(VALUES(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey])) = 1, &lt;/p&gt;

&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 1 / CALCULATE( COUNTROWS(&amp;#39;DimDate&amp;#39;), ALL(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey], &amp;#39;DimDate&amp;#39;[EnglishMonthName]) ), 
  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; 1 / CALCULATE( COUNTROWS( DISTINCT( &amp;#39;DimDate&amp;#39;[EnglishMonthName]) ), ALL(&amp;#39;DimDate&amp;#39;[EnglishMonthName]) ) 

  &lt;br /&gt;&amp;#160;&amp;#160; )&lt;/p&gt;

&lt;p&gt;The COUNTROWS(VALUES(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey])) = 1 allows me to check that we&amp;#39;re at the day level, and if we are at the day level, then count the number of days in the quarter. Otherwise, if we&amp;#39;re at the month level we calculate the number of months in the current quarter. When this DAX is put into a new measure we get the following results:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_6.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="206" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_thumb_2.png" width="402" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="justify"&gt;This produces the same results as the MDX statement. The next step was then to apply this ratio to the Sales Amount Quota for the current quarter. This was achieved using the following DAX:&lt;/p&gt;

&lt;p&gt;=IF(
  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; COUNTROWS( VALUES(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey]) ) &amp;lt; 90,

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALCULATE( Sum(&amp;#39;FactSalesQuota&amp;#39;[SalesAmountQuota]),&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; All(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey], &amp;#39;DimDate&amp;#39;[EnglishMonthName]) ) * &amp;#39;FactSalesQuota&amp;#39;[Ratio],

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sum(&amp;#39;FactSalesQuota&amp;#39;[SalesAmountQuota])

  &lt;br /&gt;&amp;#160;&amp;#160; )&lt;/p&gt;

&lt;p align="justify"&gt;The &amp;lt; 90 at the start of the statement allows me to check if we&amp;#39;re at the day level or the month level. If we&amp;#39;re at either of these levels, then we want to pick up the Quarter-level SalesAmountQuota and multiply by the ratio. Otherwise, at the Quarter and Year levels, we just apply the original SalesAmountQuota value. This produces the following results:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="203" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/AllocationsinPowerPivotUsingDAX_10A07/image_thumb_4.png" width="542" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p align="left"&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p align="justify"&gt;The use of the &lt;a href="http://msdn.microsoft.com/en-us/library/ms145989.aspx" target="_blank"&gt;MDX Scope statement&lt;/a&gt; would have been nice to pinpoint exactly where I wanted the calculation to occur, but then again, the use of IF() keeps it quite simple, which is better for an Excel power user. Whilst MDX is very very powerful, can you imagine a business user getting to grips with MDX statements such as Scope or Freeze?&lt;/p&gt;

&lt;p align="justify"&gt;The bottom line is that the DAX calculation produces exactly what I want - the new AllocatedSalesQuota measure is correct at all levels in the Calendar hierarchy. Even with an IF() statement, like everything else in PowerPivot, the calculation performs very quickly.&lt;/p&gt;&lt;img src="http://blogs.adatis.co.uk/aggbug.aspx?PostID=7569" width="1" height="1"&gt;</description><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/MDX/default.aspx">MDX</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Analysis+Services/default.aspx">Analysis Services</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Excel/default.aspx">Excel</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/PowerPivot/default.aspx">PowerPivot</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Gemini/default.aspx">Gemini</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/DAX/default.aspx">DAX</category></item><item><title>DAX Closing Balances</title><link>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2010/02/11/dax-closing-balances.aspx</link><pubDate>Thu, 11 Feb 2010 08:03:03 GMT</pubDate><guid isPermaLink="false">8d7d37f8-4a66-4c95-9fba-293fa87607dc:7565</guid><dc:creator>Jeremy Kashel</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.adatis.co.uk/blogs/jeremykashel/rsscomments.aspx?PostID=7565</wfw:commentRss><comments>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2010/02/11/dax-closing-balances.aspx#comments</comments><description>&lt;p&gt;One of the often required calculations for users in reports is to be able to calculate a point-in-time closing balance, which is especially relevant when dealing with stock levels or financial data.&lt;/p&gt;  &lt;p&gt;In the Analysis Services world, at least in the Enterprise Edition, we&amp;#39;re lucky that we have a variety of &lt;a href="http://msdn.microsoft.com/en-us/library/ms365396.aspx" target="_blank"&gt;Aggregation Functions&lt;/a&gt; that can deal with semi-additive measures such as a closing balance. Or we can always turn to MDX if we need to which will achieve the same thing.&lt;/p&gt;  &lt;p&gt;In PowerPivot, we don&amp;#39;t have Aggregation Functions, but there is DAX, which has a variety of time intelligence functions up its sleeve. The idea behind this post is to see how PowerPivot would deal with the requirement of reporting a closing balance measure.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;DAX Time Intelligence Functions&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One of the DAX functions that we can use for our closing balance is called &lt;a href="http://msdn.microsoft.com/en-us/library/ee634215(SQL.105).aspx" target="_blank"&gt;ClosingBalanceMonth()&lt;/a&gt;, which will simply evaluate an expression at the end of a given month. There&amp;#39;s also the similar &lt;a href="http://msdn.microsoft.com/en-us/library/ee634876(SQL.105).aspx" target="_blank"&gt;ClosingBalanceQuarter()&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ee634562(SQL.105).aspx" target="_blank"&gt;ClosingBalanceYear().&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;Having noticed these functions within PowerPivot, my first port of call was to set up a simple PowerPivot model by taking data from the FactInternetSales table in AdventureWorksDW, plus all it&amp;#39;s related dimensions of course. What I ended up with was the following simple pivot table in Excel 2010:&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/DAXClosingBalances_E850/image_4.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="234" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/DAXClosingBalances_E850/image_thumb_1.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="left"&gt;Sales Amount obviously isn&amp;#39;t a semi-additive measure, but I&amp;#39;m treating it as one in this example. My first port of call was to use ClosingBalanceMonth() to try and get the value for the month to be equal to the value for last day in the month. I managed to come up with the following formula:&lt;/p&gt;  &lt;p&gt;=CLOSINGBALANCEMONTH(Sum([SalesAmount]), &amp;#39;DimDate&amp;#39;[FullDateAlternateKey], ALL(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey]))&lt;/p&gt;  &lt;p align="left"&gt;This produces the results that are shown below, in the measure called ClosingBalanceFormula:&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/DAXClosingBalances_E850/image_6.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="469" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/DAXClosingBalances_E850/image_thumb_2.png" width="344" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="left"&gt;It does a good job of calculating a closing balance for each month, but it presents that closing monthly balance on each day. Therefore, I started looking for an alternative approach and found the &lt;a href="http://msdn.microsoft.com/en-us/library/ee634380(SQL.105).aspx" target="_blank"&gt;LastDate()&lt;/a&gt; function. It returns the last date that&amp;#39;s in context for the passed date column. The last date that&amp;#39;s in context at the month level will be the last date in the month, but thankfully the last date that&amp;#39;s in context at the day level will be the current day. Therefore I came up with the following formula:&lt;/p&gt;  &lt;p&gt;=&amp;#39;FactInternetSales&amp;#39;[Sum of SalesAmount](LASTDATE(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey]))&lt;/p&gt;  &lt;p align="left"&gt;This produced the results that I wanted - the daily closing balance at the day level and the monthly closing balance at the month level:&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/DAXClosingBalances_E850/image_8.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="326" alt="image" src="http://blogs.adatis.co.uk/blogs/jeremykashel/WindowsLiveWriter/DAXClosingBalances_E850/image_thumb_3.png" width="500" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p align="left"&gt;A bit more digging lead me to find out that a combination of the Calculate() and LastDate() functions gets to the same result, as an alternative. That formula is:&lt;/p&gt;  &lt;p&gt;=CALCULATE(Sum(&amp;#39;FactInternetSales&amp;#39;[SalesAmount]), LASTDATE(&amp;#39;DimDate&amp;#39;[FullDateAlternateKey]))&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;It&amp;#39;s a shame that the ClosingBalanceMonth() formula didn&amp;#39;t quite work, but perhaps getting that approach to work will come out in the wash with more DAX experience. However, as with MDX or any kind of expression language, there&amp;#39;s always going to be a load of different ways to get to the same result. It&amp;#39;s much more efficient to work knowing that you&amp;#39;ve got several ways around a particular problem, rather than being forced down a particular path, and in fact, I think the range of calculation functions available shows the richness of the DAX language.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ee5c5cde-dce9-4dee-91e0-948dabcbe160" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/PowerPivot" rel="tag"&gt;PowerPivot&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Gemini" rel="tag"&gt;Gemini&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DAX" rel="tag"&gt;DAX&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.adatis.co.uk/aggbug.aspx?PostID=7565" width="1" height="1"&gt;</description><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Analysis+Services/default.aspx">Analysis Services</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Excel/default.aspx">Excel</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/PowerPivot/default.aspx">PowerPivot</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Gemini/default.aspx">Gemini</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/DAX/default.aspx">DAX</category></item><item><title>PowerPivot CTP3 Released</title><link>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2009/11/18/powerpivot-ctp3-released.aspx</link><pubDate>Wed, 18 Nov 2009 22:08:56 GMT</pubDate><guid isPermaLink="false">8d7d37f8-4a66-4c95-9fba-293fa87607dc:7551</guid><dc:creator>Jeremy Kashel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.adatis.co.uk/blogs/jeremykashel/rsscomments.aspx?PostID=7551</wfw:commentRss><comments>http://blogs.adatis.co.uk/blogs/jeremykashel/archive/2009/11/18/powerpivot-ctp3-released.aspx#comments</comments><description>&lt;p&gt;Following last week&amp;#39;s release of the November CTP for SQL Server 2008 R2, the latest CTP for PowerPivot is now also released!&lt;/p&gt;  &lt;p&gt;The links for the downloads are:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=168583&amp;amp;clcid=0x409" target="_blank"&gt;32 Bit PowerPivot Download&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=168584&amp;amp;clcid=0x409" target="_blank"&gt;64 Bit PowerPivot Download&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=48a5b47b-8c9c-450f-ab6e-178600a733ca&amp;amp;displaylang=en" target="_blank"&gt;PowerPivot Main Download Page&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Included in the new CTP3 features are several new DAX functions, especially quite a few around time intelligence. Some look quite comparable to MDX, whereas others possibly give even more functionality than MDX. This is something I hope to blog about soon.....&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c6c42134-6233-4ffa-90b7-638dc74a5006" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/PowerPivot" rel="tag"&gt;PowerPivot&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Gemini" rel="tag"&gt;Gemini&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Excel" rel="tag"&gt;Excel&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.adatis.co.uk/aggbug.aspx?PostID=7551" width="1" height="1"&gt;</description><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Excel/default.aspx">Excel</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/PowerPivot/default.aspx">PowerPivot</category><category domain="http://blogs.adatis.co.uk/blogs/jeremykashel/archive/tags/Gemini/default.aspx">Gemini</category></item></channel></rss>