<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PowerPivotPro &#187; Quick Tips &amp; Tricks</title>
	<atom:link href="http://www.powerpivotpro.com/category/quick-tips-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powerpivotpro.com</link>
	<description>Thoughts on PowerPivot, Sharepoint BI and the occasional movie quote</description>
	<lastBuildDate>Thu, 09 Feb 2012 07:11:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Lookups based on date ranges</title>
		<link>http://www.powerpivotpro.com/2012/02/lookups-based-on-date-ranges/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=lookups-based-on-date-ranges</link>
		<comments>http://www.powerpivotpro.com/2012/02/lookups-based-on-date-ranges/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 05:01:00 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[Accounting/Financial Techniques]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=3744</guid>
		<description><![CDATA[Another one from the Mr. XL Forum! …and the word “forum” gives me an excuse for a blast from the past… “What you are about to witness is real. The participants are not actors.&#160; They have agreed to dismiss their tech support cases and have their questions settled here, in our forum: THE POWERPIVOT COURT [...]]]></description>
			<content:encoded><![CDATA[<h3>Another one from the <a href="http://www.mrexcel.com/forum/forumdisplay.php?f=29"><u><font color="#4f81bd">Mr. XL Forum</font></u></a><u><font color="#4f81bd">!</font></u></h3>
<p>…and the word “forum” gives me an excuse for a blast from the past…</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image19.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="PowerPivot Court" border="0" alt="PowerPivot Court" src="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image_thumb18.png" width="462" height="326"></a></p>
<p align="center"><font face="Arial"><font size="2">“What you are about to witness is real. The participants are not actors.&nbsp; They have agreed to dismiss their tech support cases and have their questions settled here, in our forum: <br /><b>THE POWERPIVOT COURT</b></font></font></p>
<p align="center"><strong><a href="http://www.youtube.com/watch?v=7iTqoDH0vFU" target="_blank">(Click here for theme music!)</a></strong></p>
<h3>The much-neglected calculated column</h3>
<p>OK, neglected by me, not by everyone else.&nbsp; At Pivotstream I have the benefit of a great SQL team.&nbsp; Generally speaking, when I need a calculated column, I ask them to provide it.&nbsp; The benefits of doing that are documented several places on this site, <a href="http://www.powerpivotpro.com/2011/11/why-powerpivot-is-better-fed-from-a-database-pt-1/"><strong>including here</strong></a><strong>&nbsp;</strong>and<strong> <a href="http://www.powerpivotpro.com/2011/11/why-powerpivot-is-better-fed-from-a-database-pt2/">continued here</a>.</strong></p>
<p>But hey, not everyone has a database rapid-response team at their disposal <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://www.powerpivotpro.com/wp-content/uploads/2012/02/wlEmoticon-sadsmile1.png"></p>
<p>So questions like this one come up a lot on the forums, reminding me of my blind spot:</p>
<p>You have two tables of data.&nbsp; In one, you have a list of your clients and their effective discount rate during particular date ranges – marked by a start and an end date.&nbsp; If the End date is blank, that discount rate is assumed to still be active.</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image15.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image_thumb14.png" width="466" height="410"></a></p>
<p align="center"><strong>Rates Table:&nbsp; Discount Rate per Client, <br />Over Distinct Date Ranges (Start and End Effective Date)</strong></p>
<p>Then there’s a second table, listing Clients and the days that you called each of them:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image16.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Multiple Clients, and Multiple Calls to Each Client in PowerPivot" border="0" alt="Multiple Clients, and Multiple Calls to Each Client in PowerPivot" src="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image_thumb15.png" width="294" height="345"></a></p>
<p align="center"><strong>Calls Table:&nbsp; Multiple Clients, and Multiple Calls to Each Client</strong></p>
<h3>Desired Result</h3>
<p>You want to add a calculated column to that Calls table which contains that client’s effective discount rate on the date of the call:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image17.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Calc Column in PowerPivot Looking Up a Value Based on Date Ranges in Another Table" border="0" alt="Calc Column in PowerPivot Looking Up a Value Based on Date Ranges in Another Table" src="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image_thumb16.png" width="449" height="306"></a></p>
<p align="center"><strong>We Want to Add the Highlighted Calc Column – What’s the Formula?</strong></p>
<p>So… what’s the formula?</p>
<p><font size="3" face="Courier New">=CALCULATE(AVERAGE(Rates[Rate]), <br />&nbsp;&nbsp; FILTER(Rates, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rates[Start]&lt;=Calls[ContactDate] &amp;&amp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rates[EffectiveEnd] &gt;= Calls[ContactDate] &amp;&amp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rates[Client]=Calls[Client]<br />&nbsp;&nbsp; )<br />)</font></p>
<h3>Hey, That’s a Lot Like a Measure!</h3>
<p>Yeah, it IS a lot like a measure.&nbsp; It uses <strong><a href="http://www.powerpivotpro.com/2009/12/powerpivot-dax-calculate-is-a-supercharged-sumif/">CALCULATE, the wonder function</a></strong>. </p>
<p>But in this case, we’re just using CALCULATE to apply filters in our calculated column.</p>
<p>Works basically the same way, though.&nbsp; The three clauses in the FILTER() function are all AND’d together using the &amp;&amp; operator, so that only rows from the Rates table meeting the following three criteria are “kept” and then “fed” to the AVERAGE function:</p>
<ol>
<li>The Start date in the rates table must be prior to (or equal to) the Contact Date in the Calls table.
<li>The End date in the rates table must be after (or equal to) the Contact Date in the Calls table.
<li>The Client ID in the rates table must match the Client ID in the Calls table </li>
</ol>
<p><strong>Note for those who desire deeper understanding:</strong>&nbsp; The biggest difference between this calc column formula and a similar formula we’d have to write in a measure is that in a measure, we’d have to use the <strong><a href="http://www.powerpivotpro.com/2011/03/the-magic-of-ifvalues/">VALUES()</a></strong> function wrapped around the right hand side of the criteria – VALUES(Calls[ContactDate]) rather than just Calls[ContactDate]).&nbsp; And we’d have to “protect” those VALUES functions with an IF(COUNTROWS()) since you can’t use VALUES() as part of an “=” test, <strong><a href="http://www.powerpivotpro.com/2011/03/the-magic-of-ifvalues/">except when there is only one value returned</a></strong>, or maybe use MAX() instead of VALUES().&nbsp; The point is that in a calc column, we DO have a current row in the table, so we don’t need the wrapper function like we do in a measure.</p>
<h3>What’s that EffectiveEndDate column?</h3>
<p>Yeah I sneaked that one in.&nbsp; It’s another calc column I added to the Rates table:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image18.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/02/image_thumb17.png" width="626" height="423"></a></p>
<p>You can see its formula in the formula bar in the image above.&nbsp; I just wanted to put a non-blank value in whenever End was blank.&nbsp; You could hard-code a date in there if you wanted, or use TODAY() and a much bigger number than 365.&nbsp; I just figured that setting a date one year in the future from today is good.&nbsp; Keep in mind though that TODAY() will only be re-evaluated when you refresh your data or force a re-calc.</p>
<h3>Is There a Relationship Between Those Two Tables?</h3>
<p>No, there is not.&nbsp; Neat huh?&nbsp; And really, there couldn’t be anyway – each Client ID appears more than once in each table, and PowerPivot doesn’t handle relationships on “many to many” like that.&nbsp; The date columns are even less “relationship friendly” since they don’t match up at all, and are based on ranges in one table and single dates in the other.</p>
<h3>Download the Workbook</h3>
<p>I’m trying to do this more often, especially with the forum questions.</p>
<p align="center"><strong><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/02/EffectiveClientRatesByDate.xlsx" target="_blank"><font size="3">Download the workbook here</font></a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2012/02/lookups-based-on-date-ranges/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mini Post #3:  Measures Can Return Text!</title>
		<link>http://www.powerpivotpro.com/2012/01/mini-post-3-measures-can-return-text/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mini-post-3-measures-can-return-text</link>
		<comments>http://www.powerpivotpro.com/2012/01/mini-post-3-measures-can-return-text/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 16:51:32 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[Usability and Appearance]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=3663</guid>
		<description><![CDATA[&#160; Yes, That IS a Measure Third and Final Mini-Post for Today Got a question from a friend yesterday that made me realize I should share this:&#160; in PowerPivot, your formulas do NOT have to return numbers.&#160; As I’ve shown several times, they can return dates, but they can also return just plain and simple [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<br /><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image31.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb25.png" width="536" height="522"></a></p>
<p align="center"><strong><font size="2">Yes, That IS a Measure</font></strong></p>
<h3>Third and Final Mini-Post for Today</h3>
<p>Got a question from a friend yesterday that made me realize I should share this:&nbsp; in PowerPivot, your formulas do NOT have to return numbers.&nbsp; As I’ve shown several times, they can return dates, but they can also return just plain and simple text.</p>
<p>For instance, check out the formula for that Trend measure above:</p>
<p><font size="3" face="Courier New">[Trend] = IF([$ - Sales] &gt; [$ - Sales YAG], &#8220;Up&#8221;, &#8220;Down&#8221;)</font></p>
<p>[$ – Sales] and [$ – Sales YAG] are both measures (“current sales” and “sales year ago.”)&nbsp; So this IF() is 100% dynamic and responds to whatever fields and filtering/slicing you’ve done on your pivot!&nbsp; If sales have gone up since last year, it returns “Up,” otherwise it returns “Down.”</p>
<p>One of those cool little tricks that comes in handy from time to time <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/wlEmoticon-smile5.png"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2012/01/mini-post-3-measures-can-return-text/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Data of Different Grains:  A Followup</title>
		<link>http://www.powerpivotpro.com/2012/01/data-of-different-grains-a-followup/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=data-of-different-grains-a-followup</link>
		<comments>http://www.powerpivotpro.com/2012/01/data-of-different-grains-a-followup/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 05:03:37 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[Custom Calendars]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=3647</guid>
		<description><![CDATA[&#160; Sales Measure Returns the Same Value for Everything:&#160; We Solved the Calendar/Periods Problem But Now We Have a Products/Category Problem Quick Recap:&#160; We Created a Separate “Periods” Table In last week’s post, I explained how PowerPivot can very easily help you solve the “Budget vs. Actuals” problem or any other problem where you have [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<br /><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image18.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb14.png" width="514" height="451"></a></p>
<p align="center"><strong>Sales Measure Returns the Same Value for Everything:&nbsp; We Solved the Calendar/Periods<br /> Problem But Now We Have a Products/Category Problem</strong></p>
<h3 align="left">Quick Recap:&nbsp; We Created a Separate “Periods” Table</h3>
<p align="left"><strong><a href="http://www.powerpivotpro.com/2012/01/salesbudget-integrating-data-of-different-grains/">In last week’s post</a></strong>, I explained how PowerPivot can very easily help you solve the “Budget vs. Actuals” problem or any other problem where you have data sets of different granularities that you want to compare in a single report.</p>
<p align="left">The crux of the problem in my example was that my Budget table only budgeted down to the Month level whereas my Sales table went down to the day level.</p>
<p align="left">To solve that, I created a separate table that only contained months (no sales or budget data, just months), and assigned a “PeriodID” to each month.&nbsp; (I could have just as easily called it MonthId).</p>
<p align="left"><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image19.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb15.png" width="429" height="288"></a></p>
<p align="center"><strong>The Newly-Created Periods Table</strong></p>
<p align="left">I then linked that PeriodID column to the PeriodID column that already existed in my Budget table:</p>
<p align="left"><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image20.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb16.png" width="450" height="329"></a></p>
<p align="left">And then created a new PeriodID column in my Sales table using a formula:</p>
<p align="left"><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image21.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb17.png" width="520" height="223"></a></p>
<p align="left">Resulting in a three-table setup that looks like this:</p>
<p align="left"><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image22.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb18.png" width="423" height="345"></a></p>
<p align="left">Which then allows me to use fields from that Periods table on slicers (or on rows or columns) while using measures from both Sales and Budget in the same pivot:</p>
<p align="left"><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image23.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb19.png" width="431" height="455"></a></p>
<p align="left">And that, my friends, is a very useful thing indeed.</p>
<h3 align="left">Could I have just added the PeriodID column to Sales and Stopped?</h3>
<p>This is an important question for us to stop and consider.&nbsp; Once I had a PeriodID column in both Sales and Budget, <strong>could I have skipped the creation of the Periods table and just moved on?</strong></p>
<p><strong>No.&nbsp; I could not.</strong>&nbsp; And there are two reasons.</p>
<p><strong><em>Reason #1:</em></strong>&nbsp; I can’t create a relationship between Sales and Budget.</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image24.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb20.png" width="568" height="333"></a></p>
<p align="center"><strong>Each PeriodID Appears More than Once in Each Table, So You Can’t Relate <br />Sales Directly to Budget or Vice Versa</strong></p>
<p>That’s just the way relationships work.&nbsp; The matching column needs to be unique (no value appears more than once) in at least one of the two tables.&nbsp; No need to really worry about why, but if you think about how VLOOKUP works when you set the last argument to FALSE, it’s pretty similar.</p>
<p><strong><em>Reason #2:</em></strong>&nbsp; Without a relationship, PeriodID from one table doesn’t work with measures from the other.</p>
<p>Look what happens to Budget measures if I use PeriodID from the Sales table:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image25.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb21.png" width="633" height="314"></a></p>
<p align="center"><strong>PeriodID from Sales Table Results in Broken Budget Measures <br />(and a relationship warning)</strong></p>
<p>Yep, all busted.&nbsp; And if I use PeriodID from the Budget table, I’ll get good Budget numbers but the Sales numbers will be hosed instead.</p>
<p>THAT is why the third, new, separate Periods table is required.&nbsp; When I use fields from THAT table on my pivot, I can use measures from both Sales and Budget at the same time and nothing is broken.</p>
<p>So we use the Periods table as a master filter of sorts, one that can drive filters down into both Sales and Budget.</p>
<h3>“Master Filter” Table is a MUCH better description than “Bridge”</h3>
<p>I debated using a “bridge” metaphor to describe the role of the Periods table but I think that’s misleading – a bridge helps you travel from point A to point B:&nbsp; A –&gt; Bridge –&gt; B.&nbsp; That would make you think that we’re “starting” on the Sales table and “traversing” the Periods table to get to the Budget table.</p>
<p>But that’s not how it works.&nbsp; Neither Sales nor Budget is “in charge” here – neither is the starting point.&nbsp; There are two separate paths here:&nbsp; Periods –&gt; Sales, and Periods –&gt; Budget.&nbsp; The diagram drives that home:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image26.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb22.png" width="423" height="345"></a></p>
<p>So you should think of the Periods table as being “in charge” here.&nbsp; Which makes sense, since you have to use it on the pivot, and can’t use PeriodID from either Sales or Budget.</p>
<h3>Extending that Rule to Fields Other than PeriodID</h3>
<p>This is the crux of what I left out of my previous post, and it’s an important rule to drive home:</p>
<p><strong><font size="2">When you have separate data tables that cannot be combined into a single table (as is the case with Sales and Budget), you CANNOT use row/column/slicer fields from one table in a pivot with measures from the other table.&nbsp; You MUST have a separate “master filter” table, and use fields from THAT table in your pivot.</font></strong></p>
<p>So does that apply to fields other than PeriodID?&nbsp; You betcha.&nbsp; Guess what happens if you use a Product Subcategory or similar field from the Budget table in a pivot that contains a Sales measure (or vice versa)?&nbsp; Yeah, same problem as trying to use PeriodID from Sales as we did above:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image27.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb23.png" width="514" height="451"></a></p>
<p>What’s the solution?&nbsp; A separate master filter table for Products!</p>
<p>And that may be as simple as a single column:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image28.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb24.png" width="242" height="470"></a></p>
<h3>Wash, Rinse, Repeat</h3>
<p><strong>Once you have measures from two different data tables, every row/column/slicer field you use requires a separate master filter table.</strong></p>
<p>It may sound tedious but it’s actually quite quick.&nbsp; To easily create such a table <strong>you can even just use&nbsp; a pivot:</strong>&nbsp; </p>
<ol>
<li>Put the ProductSubCat field from either Sales or Budget on rows.</li>
<li>Copy/paste that column of unique values into PowerPivot as a new table.</li>
<li>Create the relationships to Sales and Budget.&nbsp;&nbsp; </li>
<li>Use fields from the newly created master filter table in your pivot.&nbsp; Done.</li>
</ol>
<p>(Better to get someone to add a new view or table to a database for you if that’s available, but copy/paste works well otherwise).</p>
<h3>Also Useful for Single Table Situations!</h3>
<p>One last point:&nbsp; even when you only have a single table of data, like Sales, it’s often still quite useful to create separate master filter tables.</p>
<p>Why is that?</p>
<p>Because when you create master filter tables, it gives you the opportunity to remove lots of columns from your “big” table.</p>
<p>Imagine a sales table that, in addition to columns like Quantity and Amount, also contains columns like CustomerID, CustomerGender, CustomerAge, CustomerAddress1, CustomerAddress2, etc.</p>
<p>If you leave CustomerID in the sales table but “move” all of the other customer columns into a separate Customer table, and then link the two tables by Customer ID, you can reduce the number of columns in your Sales table by a significant number.</p>
<p>And that can sometimes shrink your files dramatically, AND speed them up.&nbsp; <strong><a href="http://www.powerpivotpro.com/2011/08/less-columns-more-rows-more-speed/">See this post for an example</a></strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2012/01/data-of-different-grains-a-followup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sales/Budget: Integrating Data of Different &#8220;Grains&#8221;</title>
		<link>http://www.powerpivotpro.com/2012/01/salesbudget-integrating-data-of-different-grains/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=salesbudget-integrating-data-of-different-grains</link>
		<comments>http://www.powerpivotpro.com/2012/01/salesbudget-integrating-data-of-different-grains/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 16:17:58 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[Accounting/Financial Techniques]]></category>
		<category><![CDATA[Custom Calendars]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=3503</guid>
		<description><![CDATA[&#160; Latest Article for CIMA Insight Some of you know that I’ve been writing a series of articles for the Chartered Institute of Management Accounts, aka CIMA.&#160; Up until this point those articles have either focused on the organizational impact, the “why” of PowerPivot.&#160; Things like how it contrasts with traditional BI and traditional spreadsheets.&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<br /><a href="http://www.flickr.com/photos/saz/33877971/" target="_blank"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image9.png" width="559" height="210"></a></p>
<h3>Latest Article for CIMA Insight</h3>
<p>Some of you know that I’ve been writing a series of articles for the Chartered Institute of Management Accounts, aka CIMA.&nbsp; Up until this point those articles have either focused on the organizational impact, the “why” of PowerPivot.&nbsp; Things like <strong><a href="http://www.cimaglobal.com/en-gb/Thought-leadership/Newsletters/Insight-e-magazine/Insight-2011/Insight-August-2011/Excel-extras-introducing-PowerPivot/" target="_blank">how it contrasts with traditional BI and traditional spreadsheets</a></strong>.&nbsp; How it <strong><a href="http://www.cimaglobal.com/en-gb/Thought-leadership/Newsletters/Insight-e-magazine/Insight-2011/Insight-October-2011/Excel-extras-using-PowerPivot-for-BI-projects/" target="_blank">saves costs and delivers more</a></strong>.</p>
<p>And then I started to introduce basic topics that have already been covered at length here on this blog, just simple how-to-get-started stuff.</p>
<p>But this month is the first time I wrote something for CIMA that I have not really covered here.</p>
<h3>The Problem:&nbsp; 60k Sales Rows vs. 2k Budget Rows</h3>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="PowerPivot Sales Data Very Granular Day Level" border="0" alt="PowerPivot Sales Data Very Granular Day Level" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb7.png" width="581" height="260"></a></p>
<p align="center"><strong>Sales Table with 60 Thousand Rows</strong></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image11.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="PowerPivot Budget Table Less Granular Month Level" border="0" alt="PowerPivot Budget Table Less Granular Month Level" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb8.png" width="530" height="264"></a></p>
<p align="center"><strong> Budget Table with Two Thousand Rows</strong></p>
<h3>The Desired Result:&nbsp; A Single Unified Report</h3>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="PowerPivot Report Combining Day Level Actual Sales and Month Level Budget Granularities" border="0" alt="PowerPivot Report Combining Day Level Actual Sales and Month Level Budget Granularities" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image_thumb9.png" width="475" height="502"></a></p>
<h3>The Solution</h3>
<p><a href="http://www.cimaglobal.com/en-gb/Thought-leadership/Newsletters/Insight-e-magazine/Insight-2012/Insight-January-2012/Excel-extras-January-2012/" target="_blank"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Diagram of How to Integrate Different Granularities of Data in PowerPivot" border="0" alt="Diagram of How to Integrate Different Granularities of Data in PowerPivot" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/image13.png" width="490" height="401"></a></p>
<p>Here’s where I have simplified it a bit for the introductory audience.&nbsp; I likely have a Calendar table in a well-designed model, and that doesn’t appear in the diagram.&nbsp; I also likely have to solve for more than just Time granularity – the Budget is also likely less granular at the Product level as well.</p>
<p>But to introduce this powerful concept, I think a simple example is best so I kept it clean.</p>
<p align="center"><strong><font size="3"><a href="http://www.cimaglobal.com/en-gb/Thought-leadership/Newsletters/Insight-e-magazine/Insight-2012/Insight-January-2012/Excel-extras-January-2012/" target="_blank">Click here to read the full (short) article and see the details of how I create the linkage between the two tables.</a></font></strong></p>
<h3>Popular Topic This Month!</h3>
<p>Everyone has this on the brain this month it seems <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/wlEmoticon-smile1.png"></p>
<p>First, in the exact same issue of CIMA, there’s an article about handling <a href="http://www.cimaglobal.com/en-gb/Thought-leadership/Newsletters/Insight-e-magazine/Insight-2012/Insight-January-2012/Spreadsheet-skills-Modelling-Actual-versus-Budget/" target="_blank"><strong>Sales vs. Budget using traditional Excel</strong></a>.</p>
<p>And Marco Russo has <strong><a href="http://www.sqlbi.com/articles/budget-and-other-data-at-different-granularities-in-powerpivot/" target="_blank">written one about this same topic</a></strong> in PowerPivot and BISM Tabular.&nbsp; As usual, his approach is excellent, and quite different from what my more primitive mind conjures.</p>
<p>I didn’t even have to use the Boot Signal:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/image18.png" target="_blank"><img style="margin: 0px auto; display: block; float: none" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/image18.png" width="156" height="121"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2012/01/salesbudget-integrating-data-of-different-grains/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Switching Subtotals On &amp; Off Dynamically Using DAX in PowerPivot</title>
		<link>http://www.powerpivotpro.com/2012/01/switching-subtotals-on-off-dynamically-using-dax-in-powerpivot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=switching-subtotals-on-off-dynamically-using-dax-in-powerpivot</link>
		<comments>http://www.powerpivotpro.com/2012/01/switching-subtotals-on-off-dynamically-using-dax-in-powerpivot/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 11:35:30 +0000</pubDate>
		<dc:creator>David Churchward</dc:creator>
				<category><![CDATA[Accounting/Financial Techniques]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[BI]]></category>
		<category><![CDATA[Cash Flow Statement]]></category>
		<category><![CDATA[COUNTROWS]]></category>
		<category><![CDATA[COUNTX]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[PowerPivot]]></category>
		<category><![CDATA[Subtotals]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=3409</guid>
		<description><![CDATA[Guest Post by David Churchward Subtotals on or off for a field - They’re the options that you get.  That’s probably great for a lot of situations, but I would put money on the majority of readers of this post having had a situation where they’ve asked “where’s the option to not display a subtotal [...]]]></description>
			<content:encoded><![CDATA[<p><em>Guest Post by </em><strong><a href="http://linkd.in/pNwvk4" target="_blank">David Churchward</a></strong></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/Cash-Flow-Statement-With-and-Without-Subtotals.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/Cash-Flow-Statement-With-and-Without-Subtotals_thumb.jpg" alt="Cash Flow Statement With and Without Subtotals" width="642" height="229" border="0" /></a></p>
<p><strong>Subtotals on or off for a field -</strong> They’re the options that you get.  That’s probably great for a lot of situations, but I would put money on the majority of readers of this post having had a situation where they’ve asked “<strong>where’s the option to not display a subtotal when there’s only one record being shown?</strong>”.  Frustrating isn’t it?  You end up with a load of subtotals simply repeating the same value as it’s own one subset member because one of your other report elements has a subset of data that <strong>does</strong> need subtotalling.  You can, of course, toggle the show and hide for each member, but wouldn’t it be better if it was dynamic?</p>
<p>Fortunately, DAX has the answer.  It’s not the answer that I would have hoped for because this one feels like it should be an option setting somewhere.  However, we can deliver the same functionality by writing it into our measures.</p>
<p>In this post, I’ll explain how to create a dynamic measure that works out whether a subtotal is needed and displays that subtotal accordingly.  I’ll be using the report that was created as part of the <a href="http://www.powerpivotpro.com/2011/12/cash-flow-statement-in-powerpivot/" target="_blank"><strong>Cash Flow Statement</strong></a><strong> </strong>post.</p>
<h3></h3>
<h3>The Subtotal Issue</h3>
<p>Let’s refer back to the final report that I created for the Cash Flow Statement.</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2012/01/Cash-Flow-Statement-With-Totals21.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2012/01/Cash-Flow-Statement-With-Totals2_thumb.jpg" alt="Cash Flow Statement With Totals2" width="642" height="423" border="0" /></a></p>
<p>In the column <strong>CF3_Name</strong>, the only subtotal that I want to see is the one on <strong>Working Capital</strong> as this is the only one that has any lower level detail.  You’ll notice that all other areas are carrying subtotals  which only serves to repeat the number above it.</p>
<h3>COUNTROWS and COUNTX</h3>
<p>In order to solve this problem, you obviously need to know how many subset elements there are that would make up your subtotal.  It would be reasonable to jump straight for <strong>COUNTROWS</strong>.  Let’s examine that quickly with a measure that we’ll call <strong>CF4_Headings_No</strong> in the hope that it will tell us how many headings are in our subset.</p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">CF4_Headings_No</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">= COUNTROWS(VALUES(CF4[CF4]))</span></span></span></span></span></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTROWS-Separate-Tables.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTROWS-Separate-Tables_thumb.jpg" alt="COUNTROWS Separate Tables" width="402" height="332" border="0" /></a></p>
<p>On the face of it, that doesn’t appear to give us what we want.  We have the same results for all headings and <strong>CF4_Name</strong> repeats all of the same headings.  The reason that this happens is because <strong>CF3_Name</strong> and <strong>CF4_Name</strong> are held on separate tables.  Although they hold relationships to the same table, PowerPivot doesn’t pre-determine which combinations of these fields exist, <strong>even at run-time</strong>.</p>
<p>So let’s look at what happens when these headings <strong>are</strong> held on the same table with the same <strong>COUNTROWS</strong> formula (but obviously changing table name etc!).</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTROWS-Same-Table.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTROWS-Same-Table_thumb.jpg" alt="COUNTROWS Same Table" width="404" height="448" border="0" /></a></p>
<p>That looks better right?  We can see all of the correct combinations of <strong>CF3_Name</strong> and <strong>CF4_Name</strong>.  On the one hand, this is good because we can distinguish the fact that Working Capital is the only element that has more than 1 subset item and therefore the only element that requires a subtotal.</p>
<p>However, there’s one big downside here.  For all other sections, we can’t distinguish between a subtotal line and a detail line.  There’s a couple more downsides here too:</p>
<ol>
<li>I have to create a table that holds all of the combinations of these headings.  This isn’t the biggest issue as I have a table called GL_Headings that holds the codes associated to these headings.  I can create a <span style="font-family: courier new"><span style="color: #000000"><strong>RELATED()</strong></span></span>measure in my PowerPivot dataset to return the heading name.  However, why bother if we don’t have to?</li>
<li>Don’t underestimate the power of the function <span style="font-family: courier new"><span style="color: #000000"><strong>COUNTROWS(VALUES(TABLE[FIELD]))</strong></span></span> returning a value of 1 which happens when headings are held as a separate table.  This opens up a whole host of functionality and it’s probably one of the most important aspects of PowerPivot in my opinion.</li>
</ol>
<h4></h4>
<h4>So, what’s the final analysis of COUNTROWS</h4>
<ol>
<li>Using COUNTROWS against a <strong>separate table with unique values for each heading </strong>gives us the means to distinguish between subtotal sections and detail sections of our report.</li>
<li>Using COUNTROWS against a <strong>combined table with heading combinations </strong>tells us the CF3 headings that carry detail where we do want to see a subtotal.</li>
</ol>
<p>I’m sure you’ve probably deduced where I’m going with this as the combination of these two elements probably tells us what we need to know to figure out whether a subtotal is required.  Unfortunately, this is not entirely true.  The problem is that the combination of these elements won’t operate in context unless the context is directly applied against the heading table (ie you put a slicer on the report for the cash flow heading elements).  What about a date slicer?  If you apply a date slicer which is a separate table, these measures won’t react.</p>
<h3></h3>
<h3>Bring on COUNTX</h3>
<p>Let’s jump straight into the DAX on this one and see what it’s doing by creating a measure called <strong>CF3_Total_Reqd</strong>.</p>
<p style="line-height: normal;margin: 0in" lang="en-US"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">CF3_Total_Reqd</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">=COUNTX(CF4,[Cash_Flow_Statement])</span></span></span></span></span></p>
<p><strong>COUNTX</strong> is analysing our CF4 table in the context of our measure <strong>[Cash_Flow_Statement]</strong> (as calculated in the <a href="http://www.powerpivotpro.com/2011/12/cash-flow-statement-in-powerpivot/" target="_blank"><strong>Cash Flow Statement</strong></a><strong> </strong>post).  The context applied to [Cash_Flow_Statement] is carried across to our <strong>COUNTX</strong> formula.  We run this against our <strong>CF4</strong> table because we want to get the number of detail heading names that carry a value in our <strong>[Cash_Flow_Statement]</strong> measure.</p>
<p>So what do we get:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTX.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTX_thumb.jpg" alt="COUNTX" width="402" height="309" border="0" /></a></p>
<p>Our <strong>CF3_Total_Reqd</strong> measure using <strong>COUNTX</strong> is telling us how many headings are used in our dataset <strong>for</strong> the <strong>MonthEndDate</strong> shown on our report.  This is exactly what we want.  What’s even more special is that if, in a particular month, our <strong>[Cash_Flow_Statement]</strong> measure only has one heading in the Working Capital section, the Working Capital Total would return a value of 1, which is a scenario when we want to switch our subtotal off.</p>
<h4>But there’s a problem</h4>
<p>Our <strong>COUNTX</strong> measure, as it stands, is returning a count where we have a heading, but it isn’t telling us when we have a valid blank entry at the <strong>CF4_Name</strong> level.  As a result, any <strong>CF3</strong> category that doesn’t carry <strong>CF4</strong> heading detail, isn’t telling us anything.  I know we have Operating Profit elements, but we’re not getting any counts returned.</p>
<p>But what if we specify the column that we’re analysing in our <strong>CF4</strong> table?  We can do this by adding in <strong>VALUES</strong> and specifying the column in our <strong>CF4</strong> table.</p>
<p style="line-height: normal;margin: 0in" lang="en-US"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">CF3_Total_Reqd</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">=COUNTX(VALUES(CF4[CF4_Name]),[Cash_Flow_Statement])</span></span></span></span></span></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTX-With-VALUES.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/COUNTX-With-VALUES_thumb.jpg" alt="COUNTX With VALUES()" width="402" height="307" border="0" /></a></p>
<p>We have a result!  And our Working Capital section is behaving itself too!</p>
<h3>And now for the Subtotal Switch On / Off Measure</h3>
<p>Consider our two measures:</p>
<ol>
<li><strong>CF3_Total_Reqd</strong> this tells us when a total is required ie <strong>CF3_Total_Reqd &gt; 1</strong></li>
<li><strong>CF3_Total_Reqd</strong> also tells us where detailed elements exist, ie returns a value of 1, but this measure does the same for those associated subtotals.  <strong>CF4_Headings_No</strong>, at the same time, helps us distinguish, generally and irrespective of context, between detail and subtotal levels on our report ie <strong>CF3_Total_Reqd = 1 AND CF4_Headings_No = 1</strong></li>
</ol>
<p>If we combine these elements, we get a measure that we’ll call <strong>Cash_Flow_Heading_Tidy</strong></p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">Cash_Flow_Heading_Tidy</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">=IF(</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">[CF3_Total_Reqd]&gt;1||</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.75in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">([CF3_Total_Reqd]=1&amp;&amp;[CF4_Headings_No]=1),</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">[Cash_Flow_Statement],</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">BLANK()</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">)</span></span></span></span></span></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/Cash-Flow-Statement-Major-Subtotals.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/Cash-Flow-Statement-Major-Subtotals_thumb.jpg" alt="Cash Flow Statement Major Subtotals" width="642" height="458" border="0" /></a></p>
<p>That gives us what we want, right?  Well not quite.  The <strong>Cash Flow From Operations</strong> section is now right.  However, the other sections in my <strong>CF2_Name</strong> column have reached the criteria for their totals to be eliminated.  If I don’t want this effect (and I don’t because this is a major total), I have to specify for my <strong>Cash_Flow_Heading_Tidy</strong> to directly include those totals.</p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">Cash_Flow_Heading_Tidy</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">=IF([CF3_Total_Reqd]&gt;1||</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.75in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">([CF3_Total_Reqd]=1&amp;&amp;[CF4_Headings_No]=1)||</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 1.125in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small"><strong>COUNTROWS(VALUES(CF3[CF3_Name]))&gt;1</strong>,</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">[Cash_Flow_Statement],</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">BLANK()</span></span></span></span></span></p>
<p style="line-height: normal;margin: 0in 0in 0in 0.375in"><span style="font-family: courier new"><span style="color: #000000"><span style="font-size: small"><span style="font-size: small"><span style="font-size: small">)</span></span></span></span></span></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/12/Cash-Flow-Statement-Complete.jpg"><img style="margin: 0px 5px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://www.powerpivotpro.com/wp-content/uploads/2011/12/Cash-Flow-Statement-Complete_thumb.jpg" alt="Cash Flow Statement Complete" width="642" height="501" border="0" /></a></p>
<p>There you have it.  All subtotals behaving properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2012/01/switching-subtotals-on-off-dynamically-using-dax-in-powerpivot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding State Alpha Sort to the Sort By Slicer Trick</title>
		<link>http://www.powerpivotpro.com/2011/10/adding-state-alpha-sort-to-the-sort-by-slicer-trick/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adding-state-alpha-sort-to-the-sort-by-slicer-trick</link>
		<comments>http://www.powerpivotpro.com/2011/10/adding-state-alpha-sort-to-the-sort-by-slicer-trick/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 13:04:00 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[Slicers]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=3058</guid>
		<description><![CDATA[&#160; How can we call something SuperFriendly if it’s not sortable by State? Sorting by State!&#160; How did I miss that? In a comment on Thursday’s post, Janet asked an excellent question:&#160; what about sorting by state name? Awesome awesome awesome.&#160; Thanks Janet – of course the people who use this report are going to [...]]]></description>
			<content:encoded><![CDATA[<p>
<p>&nbsp;</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image19.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb19.png" width="242" height="164"></a></p>
<p align="center"><strong><font size="2">How can we call something SuperFriendly <br />if it’s not sortable by State?</font></strong></p>
<h3>Sorting by State!&nbsp; How did I miss that?</h3>
<p>In a comment <strong><a href="http://www.powerpivotpro.com/2011/10/user-friendly-report-sorting-with-slicers/">on Thursday’s post</a></strong>, Janet asked an excellent question:&nbsp; what about sorting by state name?</p>
<p>Awesome awesome awesome.&nbsp; Thanks Janet – of <strong><em>course</em></strong> the people who use this report are going to want that.</p>
<h3>Attempt #1 – Text Measures</h3>
<p>Given that my trick relies on sorting by HiddenSortMeasure, I somehow have to get the state name reflected in that measure.&nbsp; So I need a measure that represents StateName.</p>
<p>I don’t think this is widely known, but measures CAN return text.&nbsp; Let’s write a measure that simply returns the name of the state:</p>
<p><font size="3" face="Courier New">[StateNameMeasure]=</font></p>
<p><font size="3" face="Courier New">IF(COUNTROWS(VALUES(States[FullStateName]))=1,<br />&nbsp;&nbsp; VALUES(States[FullStateName]),<br />&nbsp;&nbsp; </font><font size="3" face="Courier New">BLANK()<br />)</font></p>
<p>If you are wondering how that formula works, by the way, I highly recommend checking out <strong><a href="http://www.powerpivotpro.com/2011/03/the-magic-of-ifvalues/">the post where I explained IF(VALUES).</a></strong></p>
<p>If I add that measure to the pivot and sort by it, I get:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image20.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb20.png" width="642" height="103"></a></p>
<p>Well, the measure worked.&nbsp; But the sort order is awful.&nbsp; Why is Missouri ahead of Alabama?&nbsp; A programmer will surely scold me for asking that, but seriously, I have no clue.</p>
<p>OK, let’s try another technique.</p>
<h3>Attempt #2 – Add a column to the States Table</h3>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image21.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb21.png" width="529" height="235"></a></p>
<p>Getting that column into PowerPivot was actually a bit trickier than I’d like it to have been, since this was a copy/pasted table.&nbsp; If this were a serious production application, I would have been using SQL as the source for this table, and I would have asked my database colleagues to add it for me.</p>
<p>But since this is, ahem, UFO data, I pasted a second, two-column States table into PowerPivot – StateName and AlphaOrder columns and related it to my original States table (and be sure to treat the new table as the Lookup table!)&nbsp; Then I used =RELATED() to add it to my original States table.</p>
<p>OK, now time for an AlphaSort measure:</p>
<p><font size="3" face="Courier New">[AlphaSort]=</font></p>
<p><font size="3" face="Courier New">MAX(States[AlphaOrder])</font></p>
<p>And that DOES sort properly:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image22.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb22.png" width="639" height="121"></a></p>
<p>BTW, I could have used MIN(), or SUM(), or even AVERAGE() instead of MAX().&nbsp; I just needed something that returns the number.</p>
<p>Now I just need to add it to my slicer table, and add another clause to the IF() in my original [HiddenSortMeasure], and…</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image23.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb23.png" width="628" height="354"></a></p>
<p align="center"><strong><font size="2">It’s Alive!!!!</font></strong></p>
<p>A bit trickier than sorting by the other columns, yes, but doable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2011/10/adding-state-alpha-sort-to-the-sort-by-slicer-trick/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>User-Friendly Report Sorting With Slicers!</title>
		<link>http://www.powerpivotpro.com/2011/10/user-friendly-report-sorting-with-slicers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=user-friendly-report-sorting-with-slicers</link>
		<comments>http://www.powerpivotpro.com/2011/10/user-friendly-report-sorting-with-slicers/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 15:47:31 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[Usability and Appearance]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/2011/10/user-friendly-report-sorting-with-slicers/</guid>
		<description><![CDATA[&#160; Yeah, It Really Works! With great Excel skill comes…&#160; insensitivity to others’ lack of it Let’s say you are a monster Excel pro.&#160; You’re a pivot master.&#160; Nothing is beyond you – even the more complex features of Excel seem easy.&#160; That’s obviously a huge strength, an asset.&#160; And PowerPivot magnifies those powers – [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp; <br /><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb10.png" width="582" height="304"></a></p>
<p align="center"><strong>Yeah, It Really Works!</strong></p>
<h3>With great Excel skill comes…&nbsp; insensitivity to others’ lack of it <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/wlEmoticon-smile3.png"></h3>
<p>Let’s say you are a monster Excel pro.&nbsp; You’re a pivot master.&nbsp; Nothing is beyond you – even the more complex features of Excel seem <em>easy</em>.&nbsp; That’s obviously a huge strength, an asset.&nbsp; And PowerPivot magnifies those powers – it gives you a much bigger stage, makes you more important, and extends the reach of your work to a lot more people than before.&nbsp; Great stuff.</p>
<p>But your skill level can also blind you.&nbsp; The people who consume your PowerPivot applications and reports are not NEARLY as Excel-savvy as you.&nbsp; The things you take for granted are often hard for them, sometimes even scary to them.</p>
<p>That can be frustrating of course, but remember:&nbsp; <strong>if they understood Excel as well as you’d like them to, there wouldn’t be so much need for your skills.</strong></p>
<h3>Failure to understand a report is not THEIR fault.&nbsp; It’s YOURS.</h3>
<p>When you share a report with someone and they can’t figure it out, your first response may very well be to groan or sigh (inwardly), and mutter to yourself about how some people can’t seem to tie their own shoes.&nbsp; Then you put on a helpful face and go explain to them how to use the report.&nbsp; You may even say something like “hey, it’s actually pretty easy once you understand.”</p>
<p>That’s a tempting trap.&nbsp; I’m not above it, trust me.&nbsp; But I know that’s the wrong first instinct, to explain to them the mechanics of how to do it, or to tell them it’s actually pretty easy.&nbsp; <strong>The right first instinct, the one I am constantly reinforcing with myself, is to think “how can I make the report easier to understand?”</strong></p>
<p>And as your work becomes more important, and makes its way further up the leadership hierarchy of your organization, it becomes even more critical to have the right first instinct.</p>
<h3>Example:&nbsp; “I Can’t Sort the Report!”</h3>
<p>Let’s say you have published the following mission-critical pivot report on UFO Sightings in the United States:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image11.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PowerPivot Report on UFO Sightings" border="0" alt="PowerPivot Report on UFO Sightings" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb11.png" width="552" height="307"></a></p>
<p>And one of the report consumers says to you “great, but how do I sort by Average Sighting Length instead?”</p>
<p>Well, you and I (the Excel pros) both know about that little dropdown don’t we?</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image12.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb12.png" width="569" height="342"></a></p>
<p align="center"><strong><font size="2">This Dropdown Scares Most People.&nbsp; Seriously, it Does.</font></strong></p>
<p>But that dropdown is scary.&nbsp; Seriously.&nbsp; The only people who don’t find it scary are Excel nerds like us.</p>
<p>And we, the Excel nerds, also know that we can right click in the Avg Sighting Len column and choose a sort option.&nbsp; <strong>Normal people don’t know that.</strong>&nbsp; Furthermore, that doesn’t work on SharePoint.&nbsp; And really, the report consumer is used to simply clicking on column headers to sort – in just about every single application they have ever used…&nbsp; except for Excel.</p>
<p>So in cases where sorting is important, can we give them something a little friendlier?&nbsp; Yes we can.</p>
<h3>Step 1:&nbsp; Create Two Dummy Tables for Slicers</h3>
<p align="center"><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image13.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb13.png" width="239" height="92"></a>&nbsp; <a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image14.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb14.png" width="176" height="92"></a></p>
<p align="left">First table just lists all the measures you’d like the user to be able to sort by.&nbsp; Second table is just Ascending/Descending (although as an added boost to friendliness, I came back and changed those to Largest to Smallest/Smallest to Largest because Ascending/Descending often confuses even me!)</p>
<p align="left">Now you can add them as slicers on the report, even though they don’t do anything yet:</p>
<p align="left"><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image15.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb15.png" width="402" height="145"></a></p>
<h3 align="left">Step 2:&nbsp; Create Measures that Detect User Selections on Those Slicers</h3>
<p><font size="3" face="Courier New"><strong>[SelectedSortMeasure]=</strong></font></p>
<p><font size="3" face="Courier New">IF(COUNTROWS(VALUES(SortBy[Sort Table By]))=1,<br />&nbsp;&nbsp; VALUES(SortBy[Sort Table By]),<br />&nbsp;&nbsp; &#8220;Total Sightings per Year&#8221;<br />)</font></p>
<p><font size="3" face="Courier New"><strong>[Selected Sort Order]=</strong></font></p>
<p><font size="3" face="Courier New">IF(COUNTROWS(VALUES(SortOrder[Sort Order]))=1,<br />&nbsp;&nbsp; VALUES(SortOrder[Sort Order]),<br />&nbsp;&nbsp; &#8220;Largest to Smallest&#8221;<br /></font><font size="3" face="Courier New">)</font></p>
<p>Both of those merely return the caption of whatever is selected.&nbsp; And if more than one thing is selected on a slicer, it returns a default value – Total Sightings per Year in the first measure.</p>
<h3>Step 3:&nbsp; Create a 1,-1 Measure Based on Sort Order</h3>
<p><font size="3" face="Courier New">[SortOrderMultiplier]=</font></p>
<p><font size="3" face="Courier New">IF([SelectedSortOrder]=&#8221;Smallest to Largest&#8221;,-1,1)</font></p>
<p>If the SortOrder measure defined above returns “Smallest to Largest” then this measure returns –1.&nbsp; Otherwise it returns 1.</p>
<h3>Step 4:&nbsp; Create a Branching Measure Based of the “Sort Table By” Slicer</h3>
<p><font size="3" face="Courier New">[HiddenSortMeasure] = </font></p>
<p><font size="3" face="Courier New">IF([SelectedSortMeasure]=&#8221;Avg Sighting Len (Mins)&#8221;, <br />&nbsp;&nbsp; [Avg Sighting Length in Mins],<br />&nbsp;&nbsp; IF([SelectedSortMeasure]=&#8221;Sightings per 100K Residents&#8221;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Sightings per 100K],<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Sightings per Year]<br />&nbsp;&nbsp; )<br />)* [SortOrderMultiplier]</font></p>
<p>This measure returns an entirely different value based on whatever the user selects on Sort Table By.&nbsp; Sometimes it “mimics” one measure, other times another.</p>
<p>And note that last line – it multiplies [SortOrderMultiplier], which is 1 or –1, by the whole thing.</p>
<h3>Step 5 – Add The HiddenSortMeasure to the Pivot, Sort By It</h3>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image16.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb16.png" width="623" height="256"></a></p>
<p>Sort the pivot by that measure.&nbsp; Notice how it is the negative version of the Total Sightings per Year measure?&nbsp; That’s expected based on the slicer selections.</p>
<h3>Step 6 – Hide that Column of the Spreadsheet</h3>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image17.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb17.png" width="281" height="384"></a></p>
<p>And the result:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image18.png"><img style="background-image: none; border-right-width: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/10/image_thumb18.png" width="530" height="354"></a></p>
<p>This is actually really easy.&nbsp; Took a lot longer to write this post than it did to add to the report.</p>
<p><strong>THIS TOPIC CONTINUED:</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong><a href="http://www.powerpivotpro.com/2011/10/adding-state-alpha-sort-to-the-sort-by-slicer-trick/">Adding “sort by state name” to this report</a></strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong><a href="http://www.powerpivotpro.com/2011/10/try-out-sort-by-slicers-ufos-in-browser-no-login/" target="_blank">Try this report out live in your browser!</a></strong></p>
<p>Next step, of course, is to make this thing look better, but that’s another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2011/10/user-friendly-report-sorting-with-slicers/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>DAX Autocomplete Stops Working&#8211;A Workable &#8220;Fix&#8221;</title>
		<link>http://www.powerpivotpro.com/2011/09/dax-autocomplete-stops-workinga-workable-fix/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dax-autocomplete-stops-workinga-workable-fix</link>
		<comments>http://www.powerpivotpro.com/2011/09/dax-autocomplete-stops-workinga-workable-fix/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 14:00:37 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence DAX]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=2701</guid>
		<description><![CDATA[&#160; “There, good as new.” By Now, You’ve Probably Seen This So you’re typing along, writing a DAX measure.&#160; And suddenly, poof!&#160; Autocomplete stops working. This happens to me all day, every day.&#160; Especially when I use the [Measure]( filter expression ) syntax.&#160; Here’s a quick “before and after” example: Autocomplete is Working for Table/Column [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<br /><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb.png" width="495" height="320"></a></p>
<p align="center"><strong><font size="3" face="Arial">“There, good as new.”</font></strong></p>
<h3>By Now, You’ve Probably Seen This</h3>
<p>So you’re typing along, writing a DAX measure.&nbsp; And suddenly, poof!&nbsp; Autocomplete stops working.</p>
<p>This happens to me all day, every day.&nbsp; Especially when I use the [Measure]( <em>filter expression</em> ) syntax.&nbsp; Here’s a quick “before and after” example:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="PowerPivot autocomplete is working" border="0" alt="PowerPivot autocomplete is working" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb1.png" width="520" height="253"></a></p>
<p align="center"><strong>Autocomplete is Working for Table/Column Names</strong></p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="PowerPivot autocomplete is NOT working" border="0" alt="PowerPivot autocomplete is NOT working" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb2.png" width="520" height="252"></a></p>
<p align="center"><strong>Same Table Name, But Autocomplete is NOT Working</strong></p>
<h3>Grab Your Duct Tape…</h3>
<p>A guy named Scott Kaylie showed me this about six months ago and I am just now getting around to posting it.&nbsp; Yes, my backlog of posts has in fact grown to be at least six months long <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/wlEmoticon-sadsmile.png"></p>
<p>Anyway, here’s the trick.&nbsp; Just put a * in between the measure and the open parenthesis, as if you were going to multiply the measure by another expression:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Tricking autocomplete into working with *" border="0" alt="Tricking autocomplete into working with *" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb3.png" width="520" height="252"></a></p>
<p>OK, so then just go ahead and finish writing the measure, leaving the * in there:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Tricking autocomplete into working with *" border="0" alt="Tricking autocomplete into working with *" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb4.png" width="520" height="252"></a></p>
<p>And then, at the very end, go back and remove the *…</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="Tricking autocomplete into working with *" border="0" alt="Tricking autocomplete into working with *" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb5.png" width="520" height="252"></a></p>
<p>Voila.&nbsp; Ugly yes, but much better than having no workaround.&nbsp; Thanks Scott.</p>
<p>Any other questions please consult the following home repair manual:</p>
<p><a href="http://graphjam.memebase.com/2011/06/30/funny-graphs-duct-tape-try-everything-tape/" target="_blank"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px auto; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top: 0px; border-right: 0px; padding-top: 0px" title="From GraphJam" border="0" alt="From GraphJam" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image7.png" width="449" height="345"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2011/09/dax-autocomplete-stops-workinga-workable-fix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Detecting ALL() &#8211; Detecting When Not Filtered</title>
		<link>http://www.powerpivotpro.com/2011/09/detecting-all-detecting-when-not-filtered/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=detecting-all-detecting-when-not-filtered</link>
		<comments>http://www.powerpivotpro.com/2011/09/detecting-all-detecting-when-not-filtered/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 13:30:56 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence DAX]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=2715</guid>
		<description><![CDATA[&#160; &#160; “I like to carry it, you never know when you’re gonna need it.” -The&#160; much-missed John Candy as Uncle Buck &#160; &#160; A technique that you may need someday File this under “you may never need this, but when you do, you’ll know it immediately.”&#160; I’d call this one a solid 4 on [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<br /><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb8.png" width="258" height="209"></a></p>
<p><font size="3" face="Arial">&nbsp;</font></p>
<p><font size="3" face="Arial"><strong>“I like to carry it, you never know when you’re gonna need it.”</strong></font></p>
<p><font size="3" face="Arial"><strong>-The&nbsp; much-missed John Candy as Uncle Buck</strong></font></p>
<h3>&nbsp;</h3>
<h3>&nbsp;</h3>
<h3>A technique that you may need someday</h3>
<p>File this under “you may never need this, but when you do, you’ll know it immediately.”&nbsp; I’d call this one a solid 4 on <strong><a href="http://www.powerpivotpro.com/2010/11/learning-dax-measures-the-spicy-function-scale/">the DAX Spicy Scale.</a></strong></p>
<p><strong>Why I needed this:</strong>&nbsp; I had two different calendar tables, one at the Date level and one that was a custom calendar, Periods table.&nbsp; Most of the measures in this model are written to be used with one table or the other, and I never have to <a href="http://en.wikipedia.org/wiki/Proton_pack#Crossing_the_Streams" target="_blank">“cross the streams.”</a></p>
<p>But then I ran into a case where a measure I had written to be used with the Periods table, suddenly needed to also be used on a pivot that was only filtered by Dates.&nbsp; And I didn’t want to write a new version of this measure (for reasons that are mostly irrelevant here).</p>
<p>Of course, when I put the Period-focused measure on a Date-focused pivot, and there were no fields from Periods on the pivot, well…&nbsp; the Period-focused measure returned junk.</p>
<p>What I decided to do, then, was detect if Periods was the aptly-named <a href="http://workbench.cadenhead.org/news/3231/sir-not-appearing-film" target="_blank">“Sir Not Appearing in This Film”</a> and then assign a Period in that case.&nbsp; In other words, <strong>detect if the Periods table was not on the pivot, and if not, FORCE a Period value into the evaluation of my measure</strong>.</p>
<h3>Detecting ALL(), or the Absence of Filter on a Field or Table</h3>
<p>Here is the final measure formula I used, color-coded for identify its parts:</p>
<p><font face="Courier New"><strong><font size="4"><font color="#0000ff">IF(COUNTROWS(Periods) = COUNTROWS(ALL(Periods))-1,</font><br />&nbsp;&nbsp; <font color="#a5a5a5">CALCULATE(</font><font color="#9b00d3"><em>My Original Measure</em></font>,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#ff0000">FILTER(Periods, Periods[Period] = [LatestPeriod])</font><br />&nbsp;&nbsp; ),<br />&nbsp;&nbsp; </font><font size="4"><font color="#9b00d3"><font color="#9b00d3"><em>My Original Measure</em></font><br /></font>)</font></strong></font></p>
<p>Let’s go part-by-part:</p>
<h3>The Detector</h3>
<p><font face="Courier New"><strong><font size="4"><font color="#0000ff">IF(COUNTROWS(Periods) = COUNTROWS(ALL(Periods))-1</font></font></strong></font></p>
<p>The “detector” counts the rows of Periods in the current pivot context, and compares that to the number of rows in the Periods table with all filters removed by ALL().&nbsp; Pretty straightforward right?</p>
<p>So…&nbsp; why the –1 at the end?&nbsp; The reasons for that are slightly academic…&nbsp; academic enough that I don’t really want to understand in great depth.&nbsp; Let’s go with&nbsp; the short version:&nbsp; in this case, when I counted the rows of ALL(Periods), ALL() was kind enough to include the “blank” row of the Periods table.</p>
<p>What’s that?&nbsp; You say you don’t HAVE a blank row in your Periods table???&nbsp; Well, neither do I.&nbsp; But you MIGHT have some rows in your Sales table that have a blank value for the [PeriodID] column.&nbsp; Or maybe you have rows in the Sales table that DO have a [PeriodID] value, but that value does not appear in your Periods table.&nbsp; Either way, you <em>implicitly</em> DO have blanks in your Periods table, and COUNTROWS(ALL()) decides to tell you about it.&nbsp; So you’ll subtract one and like it, soldier!</p>
<p>(I have not tested, honestly, whether you always need – 1 in this detector.&nbsp; If your Sales table is perfectly clean, maybe the – 1 is not needed, and maybe it is.&nbsp; Someone let me know OK?&nbsp; And I bet three-to-one that the answer comes from Italy.)</p>
<h3>The Original Measure</h3>
<p><font color="#9b00d3" size="4" face="Courier New"><em><strong>My Original Measure</strong></em></font></p>
<p>OK, this part IS straightforward.&nbsp; Whatever my original measure was named, or perhaps its full original formula, appears here.&nbsp; Moving on…</p>
<h3>The Filter for the “No Periods Selected” Case</h3>
<p><font face="Courier New"><font size="4"><strong><font color="#ff0000">FILTER(Periods, Periods[Period] = [LatestPeriod])</font></strong></font></font><font face="Courier New"><font size="4"><strong></p>
<p></strong></font></font>
<p>OK, in the case that Periods is absent from the pivot, I take the original measure and then use the FILTER function to pretend that the Periods[Period] column IS on the pivot, and filtered to a value matching the most recent period, as calculated by my [LatestPeriod] measure.</p>
<p>But really, this part is going to be VERY different based on the circumstance.&nbsp; Maybe you want to use a completely different measure, for instance.&nbsp; Or set Periods to the first period this month.&nbsp; Or the period corresponding to the current filter context from the Date table.</p>
<p>I merely included the “meat” of what I did here to drive home the intent.</p>
<h3>Two Notes</h3>
<p><strong>One</strong> – note that there is NO difference between “the Periods table is not used on the pivot at all” and “the Periods table IS on the pivot but unfiltered in the current context.”&nbsp; So if you have Periods on a slicer but nothing is selected, the detector will “go off.”&nbsp; And if you have Periods on rows, the detector will still “go off” in the grand total cell of the pivot (and maybe in certain subtotal cells as well).</p>
<p><strong>Two</strong> – I was messing around in this area when I discovered the need for the long-simmering <a href="http://powerpivotpro.com/2011/06/14/the-great-precedence-project-filter-rules-for-dax/"><strong>Precedence Project</strong></a>.&nbsp; In other words, when you start messing around with overriding filter context like I did with the FILTER() function above, and you’ve got a number of tables and relationships in play, every now and then you see something you don’t expect.&nbsp; For that reason, I plan to return to the Precedence Project shortly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2011/09/detecting-all-detecting-when-not-filtered/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Catching Multiple Slicer Selections in a Formula</title>
		<link>http://www.powerpivotpro.com/2011/09/catching-multiple-slicer-selections-in-a-formula/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=catching-multiple-slicer-selections-in-a-formula</link>
		<comments>http://www.powerpivotpro.com/2011/09/catching-multiple-slicer-selections-in-a-formula/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 12:20:12 +0000</pubDate>
		<dc:creator>powerpivotpro</dc:creator>
				<category><![CDATA[Quick Tips & Tricks]]></category>
		<category><![CDATA[Slicers]]></category>
		<category><![CDATA[PowerPivot Power Pivot Microsoft SharePoint BI Excel Business Intelligence]]></category>

		<guid isPermaLink="false">http://www.powerpivotpro.com/?p=2712</guid>
		<description><![CDATA[&#160;A long time ago I did a post on using slicer selections in Excel formulas.&#160; That technique only worked when you select single values on slicers, though – any more than one and the dreaded “(Multiple items)” foils your well-laid plans. How to handle that multi-select case became a very common question – in email [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<br />A long time ago I did a post on <strong><a href="http://www.powerpivotpro.com/2010/12/another-way-to-get-and-use-slicer-values-in-formulas/">using slicer selections in Excel formulas</a></strong>.&nbsp; That technique only worked when you select single values on slicers, though – any more than one and the dreaded “(Multiple items)” foils your well-laid plans.</p>
<p>How to handle that multi-select case became a very common question – in email and posted as comments.</p>
<p>Awhile back I responded privately to one of those requests but haven’t had time to post the solution.&nbsp; So here goes.</p>
<h3>The Solution, Summarized</h3>
<p>First, here’s a picture of the solution I came up with.&nbsp; For fun, see if you can figure out what I’m doing just by looking at it:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image8.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb6.png" width="631" height="228"></a></p>
<p>Everything in green is visible to the final report consumer (or at least, you can choose to make it so).&nbsp; Everything in grey is stuff you likely hide&nbsp; &#8211; either by hiding columns or by placing on a hidden sheet.&nbsp; The SKUID field is on the slicer (that is hooked to both pivots) and is also on the row axis of the hidden pivot, but is not included on the visible pivot.</p>
<p>Here’s the same spreadsheet, but zoomed in and with formulas visible:</p>
<p><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image9.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/image_thumb7.png" width="630" height="218"></a></p>
<p>I went ahead and uploaded this workbook so you can take a look in a hands-on manner. </p>
<p align="center"><strong><font size="3"><a href="http://www.powerpivotpro.com/wp-content/uploads/2011/09/Copy-of-Multiple-Slicer-Values-Returned-in-a-Formula-Final2.xlsx">CLICK HERE TO DOWNLOAD THE WORKBOOK</a></font></strong></p>
<p>Note that this was a PowerPivot workbook originally but I think I nuked all the data out of it, so you won’t be able to manipulate the pivots.&nbsp; No worries though – the formulas here are 100% of the technique and should work with any pivot.</p>
<p>I’m pretty sure I could simplify this a little bit if I tried, but probably not by much.&nbsp; I eagerly await everyone’s constructive input <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.powerpivotpro.com/wp-content/uploads/2011/09/wlEmoticon-smile1.png"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.powerpivotpro.com/2011/09/catching-multiple-slicer-selections-in-a-formula/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

