<?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>Excel with Monarch Training and Services &#187; Functions</title>
	<atom:link href="http://ExcelWithMonarch.com/category/functions/feed" rel="self" type="application/rss+xml" />
	<link>http://ExcelWithMonarch.com</link>
	<description>Stop working for your data. Make your data work for you.</description>
	<lastBuildDate>Thu, 17 May 2012 17:32:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Monarch is the Solution to Fiscal Year Troubles</title>
		<link>http://ExcelWithMonarch.com/functions/monarch-is-the-solution-to-fiscal-year-troubles</link>
		<comments>http://ExcelWithMonarch.com/functions/monarch-is-the-solution-to-fiscal-year-troubles#comments</comments>
		<pubDate>Thu, 17 Dec 2009 07:17:31 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Summaries]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/monarch-is-the-solution-to-fiscal-year-troubles</guid>
		<description><![CDATA[Conventional software works just fine for date based analysis if your fiscal year starts on January 1st. Excel will happily let you group dates placed in pivot tables as row or column fields into months, quarters or years. You’ll have nice looking and accurate summary tools in no time – if your fiscal dates match [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Conventional software works just fine for date based analysis if your fiscal year starts on January 1<sup>st</sup>. Excel will happily let you group dates placed in pivot tables as row or column fields into months, quarters or years. You’ll have nice looking and accurate summary tools in no time – if your fiscal dates match standard calendar periods.</p>
<p>But what about the rest of us whose fiscal years don’t line up with that? Or our fiscal periods aren’t all the same number of weeks in duration? How do we get the same results?</p>
<p>To calculate if July 2<sup>nd</sup> in a particular year was actually fiscal June or fiscal July, or in which fiscal quarter it belongs, we typically had to resort to all manner of formulas and devices. And if your quarters are comprised of a four period followed by a five week period and then another four week period, well then you’re on your own buddy. Yup, good luck with that.</p>
<p>If this sounds like a challenge that you constantly have to combat, then you’ll love day 20 of the <a href="http://excelwithmonarch.com/tips/embedding-documentation-for-better-monarch-models">30 Days to Become a Better Monarch Modeler series</a>, because the topic today is Monarch’s time interval feature. New to v10, this brilliant feature offers us special abilities to handle dates related to both atypical calendar years and fiscal years. I like this feature so much I’d swear that it was devised just to appease me.</p>
<p>By configuring your Monarch models with your specific date needs, you’ll give your models the kind of easy to implement analytical abilities that would make even the most skilled Excel modeler tremble in fear.</p>
<h3>Manipulate Space and Time with Monarch</h3>
<p>We access the Time Intervals dialog, the master control of this feature, under the Options menu. It shows samples of how various date styles will be displayed in the Table and Summary windows, including:</p>
<ul>
<li>Calendar year</li>
<li>Calendar half-year</li>
<li>Calendar quarter</li>
<li>Calendar month</li>
<li>Calendar week</li>
<li>Day</li>
<li>ISO8601 year</li>
<li>ISO8601 week</li>
<li>Fiscal year</li>
<li>Fiscal half-year</li>
<li>Fiscal quarter</li>
<li>Fiscal period, and</li>
<li>Fiscal week</li>
</ul>
<p>If you’d prefer to display a value in a different you change its “mask”.</p>
<p>If you need to customize the manner by which you define calendar weeks, you do that here. As make changes, Monarch shows you some dates to confirm the impact of your selection.</p>
<p>To make changes to the default fiscal year and its related periods, you do that here too.</p>
<p>You can choose to have your fiscal year consist of 12 calendar months. With this option, Monarch will calculate that your year begins on the first day of any month you choose.</p>
<p>Alternatively, you can define a year that contains 52 or 53 weeks. If you do, Monarch wants to know that your year starts or ends with reference to any day of the year that you specify. We’ll refer to this as “Day 1”.</p>
<p>Once that’s configured, you pick the day of the week that starts your fiscal week. We’ll refer to this as “Week Day”</p>
<p>The last requirement of this section is to tell Monarch that your year:</p>
<ul>
<li>Starts on the first Week Day on or after Day 1, or</li>
<li>Starts on the Week Day closest to Day 1, or</li>
<li>Ends on the day before the Week Day on or before Day 1, or</li>
<li>Ends on the day before the Week Day closest to Day 1.</li>
</ul>
<p>With that set up, Monarch wants to know if your year is divided into four 13-week quarter, or 13 four-week periods.</p>
<p>If you choose the former, you then select from either of a 4-4-5, 4-5-4 or 5-4-4 weekly pattern, and tell Monarch how to handle the extra week in 53 week years.</p>
<p>If you choose the latter, you simply tell Monarch which period gets the extra week in 53 week years.</p>
<p>And that’s it: you’ve defined custom date controls in your Monarch model.</p>
<p>Now it’s time to have some fun.</p>
<h3>New Date Functions</h3>
<p>Fourteen new functions have been added to Monarch to let us easily access proper date information according to the fancy fiscal year and calendar year customization. They are:</p>
<ul>
<li>CalendarWeek</li>
<li>FirstDay</li>
<li>FiscalDayOfYear</li>
<li>FiscalHalfYear</li>
<li>FiscalPeriod</li>
<li>FiscalQtr</li>
<li>FiscalWeek</li>
<li>FiscalYear</li>
<li>HalfYear</li>
<li>IsoDayOfYear</li>
<li>IsoWeek</li>
<li>IsoWeekDay</li>
<li>IsoYear and</li>
<li>LastDay</li>
</ul>
<p>I’ll let you refer to the online help for full descriptions, but the intended purpose of each function is pretty apparent just by the name. The ISO functions offer a good compromise between customized calendars and a predefined standard methodology.</p>
<p>As we’ve seen with calculated fields, any time that we utilize Monarch’s functions we introduce all kinds of possibilities, and these new functions add to our creative toolbox nicely.</p>
<h3>Using the Intervals in Summaries</h3>
<p>To take advantage of the new date powers at your disposal, first add a date field to your summary as a key field. Double-click its name in the key field list to display the dialog box and activate the Matching tab. The last option is labeled Time Interval. Select this and then pick one of the date styles (see the list above).</p>
<p>Monarch will give you a preview of the values it calculates based on your selection on the right side of the dialog.</p>
<p>Once again, Monarch shelters us from all kinds of complexity and gives mere mortals effective and easy to use tools that let us get back to doing what we’re supposed to be doing instead of forcing us to be some kind of expert technology master.</p>
<h3>Your Task for Today</h3>
<p>Make today the day that you master Monarch’s customized calendars. Test the effects of defining a fiscal year, building some calculations using the new functions and define a few summaries that employ different time intervals on the Matching tab of the field definition.</p>
<p>Now revise the calendar customization and review the effect of your changes to your calculations and summaries.</p>
<p>Becoming a better Monarch modeler means that you know what to expect your outcomes to be before you implement them, and that best way to know that is to practice, practice, and practice.</p>
<h3>Master the Space-Time Continuum</h3>
<p>Well that’s a bit of a stretch, but with a little up-front effort you’ll find that there’s little that you can’t analyze where dates are involved.</p>
<p>If today you fight with summarizing date based activity, fight no more. Instead, just excel with Monarch.</p>
<p>&#8212;</p>
<p>Continue your commitment to Become a Better Monarch Modeler with <a href="http://excelwithmonarch.com/tips/easy-ways-to-benefit-from-automating-monarch" title="Easy ways to benefit from automating Monarch">Part 21</a> of the series, or review <a href="http://excelwithmonarch.com/tips/embedding-documentation-for-better-monarch-models" title="Embedding documentation for better Monarch models">Part 19</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/monarch-is-the-solution-to-fiscal-year-troubles/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Challenging Reinforcement</title>
		<link>http://ExcelWithMonarch.com/calcfield/a-challenging-reinforcement</link>
		<comments>http://ExcelWithMonarch.com/calcfield/a-challenging-reinforcement#comments</comments>
		<pubDate>Sat, 28 Nov 2009 04:00:59 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Calculated Fields]]></category>
		<category><![CDATA[Extraction Templates]]></category>
		<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/calcfield/a-challenging-reinforcement</guid>
		<description><![CDATA[As we’re at the midpoint of the 30 Days to Become a Better Monarch Modeler series, today on day 15 I have a real-life challenge and proposed solution that I think quite nicely reinforces some of the concepts and tools that we’ve discussed so far. This week a new Monarch Forum member named MikeMetta posted [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>As we’re at the midpoint of the <a href="http://excelwithmonarch.com/summaries/a-summary-synopsis">30 Days to Become a Better Monarch Modeler</a> series, today on day 15 I have a real-life challenge and proposed solution that I think quite nicely reinforces some of the concepts and tools that we’ve discussed so far.</p>
<p>This week a new Monarch Forum member named <a href="http://www.monarchforums.com/showthread.php?t=3151">MikeMetta posted a sample multi-column address list</a> and asked for the forum’s assistance in creating a model to handle the extraction properly, as he wasn’t yet achieving the results that he needed. It was, in Mike’s own words, “tricky”.</p>
<p>Looking at his sample it was clear that Monarch, using its regular address handling facilities would have a tough time with it, due to the now-you-see-it-now-you-don’t nature of some descriptive comments that appeared within the addresses. If that weren’t enough, telephone numbers and web site addresses were tacked onto the address without any blank lines in between that information and the address.</p>
<p>What to do?</p>
<p>Instead of trying to extract different pieces with <a href="http://excelwithmonarch.com/extract/understanding-template-types">detail and append templates</a> as was being discussed as possible approaches, I began working on capturing the entire block as a single field, with the intention of breaking it up by using a few different calculations myself, and by letting Monarch do some of the heavy lifting too.</p>
<p>The method successfully extracted the sample data properly, so I thought that it might be interesting to share this with you, as this type of challenge, or variations of it, isn’t as unusual and in fact is probably pretty common.</p>
<h3>Setting it up</h3>
<p>First up was defining the <a href="http://excelwithmonarch.com/extract/extracting-data-from-multi-column-regions">multi-column region</a> which was pretty straight-forward work for a two column layout. On to the detail template…</p>
<p>Looking at the sample, the largest block was six lines long. I created a detail template that was six lines long to handle this painting the single field across the width of the column, trapping on a single alpha character at the start of the field (a non-blank trap would work too, and would probably be better for numbered companies). In the <a href="http://excelwithmonarch.com/extract/defining-fields-in-monarch">Advanced</a> tab of the field definition, I set the End Field On the end of left justification. To keep it easy for future formula building, I named the field simply as “A”, and that’s the end of the template building. On to the slice and dice work…</p>
<h3>Breaking it down</h3>
<p>The following employs <a href="http://excelwithmonarch.com/functions/employing-functions-for-specialized-tasks">functions</a> that have already been cited in this series of posts.</p>
<p>In the Table window, deriving the Company name needed a <a href="http://excelwithmonarch.com/calcfield/an-introduction-to-monarch%E2%80%99s-field-types">Character field</a> with the formula:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">TextLine(A,1)</div></div>
<p>Now the real data separations start. In order to isolate the true address data, I thought it necessary to separate each component of the block, so line 2 of the block became the field named L2 with the formula:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">TextLine(A,2)</div></div>
<p>Similarly, L3 and L4 with built with TextLine(A,3)and TextLine(A,4).</p>
<p>Now we’ve got the name and address bits broken out, but how do we get Monarch to know which lines are truly address related, and which are descriptive text? The unfortunate answer is that we can’t. At least, I can’t determine a universal solution to that. Still, where there’s a will there’s a way.</p>
<p>I added a user-edited calculated field to the model named Skip. Skip represents the number of lines to ignore in the address block after the company name, since all of the sample address showed descriptive lines, when they existed, between the company name and the address.</p>
<p>Then I keyed into the model a value of zero if no descriptive text existed for that record, or a value of one or two as applicable when descriptive text did exist, as appropriate.</p>
<p>With this prep work done, I could finally build a field that I could use to feed a Monarch Address Block. My AddBlock character field got this formula:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Company + Chr(13) + Chr(10) + If(Skip=0,L2 + Chr(13) + Chr(10) + L3, If(Skip=1,L3 + Chr(13) + Chr(10), If(Skip=2,L4,&quot;&quot;)))</div></div>
<p>Using AddBlock as the data source for an <a href="http://excelwithmonarch.com/tips/monarchs-address-block-wizard">Address Block</a>, I instructed Monarch to extract Address line 2 as “Address”, City as City, Region as State, and Postal Code as Zip Code (for US addresses in the sample). There’s the heavy lifting done as Monarch automatically populated those tough to extract bits into the table.</p>
<p>Finally, the built the Telephone field with:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">LSplit(RSplit(A,2,&quot;Telephone: &quot;,1),2,&quot;URL:&quot;,1)</div></div>
<p>and the URL field with:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RSplit(A,2,&quot;URL: &quot;,1)</div></div>
<h3>Your Task for Today</h3>
<p>With a reasonably quick effort, I’d developed a single reusable model that was able to extract all of the important data. That said, can you see a shortfall in this model as has been described? What component isn’t clearly (and entirely) isolated?</p>
<p>Your task today may be tougher than the previous tasks, but you’re now equipped to complete it. Add the functionality to the model that I didn’t describe: duplicate this model and to it add the full descriptive text that is integrated in the original address chunk, if any.</p>
<h3>Mission Accomplished</h3>
<p>While I certainly wouldn’t expect that you’d want to use an approach that employed user-edited fields when hundreds of addresses are to be extracted, but for reasonably small samples it could be a workable long-term solution. It really shouldn’t take too long to populate the Skip field for even a fairly long list of addresses, and given the end result, that time spent doing manual data entry might be viewed as a good investment.</p>
<p>Admittedly we’ve had some bumps in the road, but I hope that you stay tuned for the second half of the 30 Days to Become a Better Monarch modeler, and discover even more that you can do to excel with Monarch.</p>
<p>&#8212;</p>
<p>Continue your commitment to Become a Better Monarch Modeler with <a href="http://excelwithmonarch.com/sources/creating-new-opportunities-with-monarch" title="Creating new opportunities with Monarch">Part 16</a> of the series, or review <a href="http://excelwithmonarch.com/summaries/a-summary-synopsis" title="A summary synopsis">Part 14</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/calcfield/a-challenging-reinforcement/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Employing Functions for Specialized Tasks</title>
		<link>http://ExcelWithMonarch.com/functions/employing-functions-for-specialized-tasks</link>
		<comments>http://ExcelWithMonarch.com/functions/employing-functions-for-specialized-tasks#comments</comments>
		<pubDate>Thu, 15 Oct 2009 06:55:59 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/employing-functions-for-specialized-tasks</guid>
		<description><![CDATA[On day 10 of the 30 Days to Become a Better Monarch Modeler series, we’ll put Monarch’s functions to work to improve our models, both by facilitating finicky data extractions and by adding useful calculations that are based on the extracted data itself. On day 8, I wrote about the types of calculated fields. In [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>On day 10 of the <a href="http://excelwithmonarch.com/tips/mastering-monarch%E2%80%99s-table-window-controls-and-layout">30 Days to Become a Better Monarch Modeler series</a>, we’ll put Monarch’s functions to work to improve our models, both by facilitating finicky data extractions and by adding useful calculations that are based on the extracted data itself.</p>
<p>On day 8, I wrote about the types of calculated fields. In the Table window, functions can only be used in formula-based calculated fields, filters, user-defined functions, and in the Find dialog’s expression builder.</p>
<p>Monarch supplies us with a good number of built-in functions. So much so in fact that in order to better locate them, Monarch presents them by category. At the top right of the formula tab dialog we can change the default from “All Functions” to one of the six available groups:</p>
<ol>
<li>Date:      everything related to calculations with dates</li>
<li>String:      everything related to calculations with text (why didn’t they call it      text?),</li>
<li>Numeric:      everything related to calculations with numbers,</li>
<li>Conversion:      everything related to changing from one data type to another,</li>
<li>Special:      a handful of logical and verification functions,</li>
<li>Report:      functions which return data about the report itself, and</li>
<li>User-defined:</li>
</ol>
<p>I should mention that the term string is often used by programmers to refer to text, and to be consistent with Monarch’s terminology I’ll use it here too.</p>
<p>There’s no practical way to discuss the purpose and proper syntax for each and every function here; there are just too many of them. Besides, I’m not certain that doing that would be of any value as Datawatch has done a fantastic job of documenting each function within the formula tab. As a function is selected, the online help is displayed at the bottom of the dialog.</p>
<p>So what’s my job here today? I suppose that it’s to reinforce the need to understand what data type a function will return. Many if not most of the difficulties that I’ve seen Monarch students struggle with when creating calculated fields is not understanding why Monarch is giving them an error; most often the all too brief “Operand Types” message.</p>
<p>The “Operand Types” message is telling us that we’re mixing data types within the formula, such as attempting to divide a string value by an integer. The root cause is often not understanding the type of data that the function used in the formula will return.</p>
<h3>Functions to Assist in Modeling</h3>
<p>Some of the functions used to often assist in capturing data that is difficult to isolate in a template alone, for whatever reason, include:</p>
<ul>
<li>LSplit      and RSplit, which break up long strings into pieces based on your      instruction</li>
<li>Extract,      which seeks out particular strings or characters within a longer string</li>
<li>Left,      Right, and SubStr which extract text from the left side, right side and middle of strings</li>
<li>InTrim,      which cleans up duplicate spaces within a string, and</li>
<li>The      indispensible TextLine which, as the description indicates, can be a      life-saver by isolating a particular line within a block of text.</li>
</ul>
<h3>Functions to Improve Captured Data</h3>
<p>Even when you are able to capture data with a template alone, the results aren’t always optimal when they’ll be used for other systems or calculations. When that’s the case, some of the go-to functions include:</p>
<ul>
<li>CtoD,      which converts Characters to Dates,</li>
<li>Str,      which converts numbers to strings,</li>
<li>Val,      which converts strings to numbers, and</li>
<li>Chr,      specifically Chr(13), which represents a carriage return character and      acts like the Enter key on your keyboard.</li>
</ul>
<p>You might be wondering about that last one. Sometimes a report might have address data scattered on the report and you might have to paint the fields separately instead of within a single multi-line field. Add to that the complexity that data entry isn’t always perfect, and suddenly you’ve got, say, State and Country data appearing in the wrong place. By combining separate fields while using a “hard” return with Chr(13), as in State+Chr(13)+Country, you can then use that calculated field as the input for an Address Block (which we’ll discuss later) to have Monarch do the data cleaning for you.</p>
<h3>Your Task for Today</h3>
<p>Nobody expects you to memorize every available function in Monarch. But what you can do is begin to examine the functions. Just a couple every day will probably do. In a model that you store just for testing and experimentation purposes, build calculated fields using the functions of the day. In very little time, you’ll get familiar with them.</p>
<h3>Adding Functions Makes for Less Work</h3>
<p>Using the right function in the right role will vastly reduce the time that it takes to build accurate models, and the quality of the model too. Instead of fighting with particular trapping methods, and potentially re-inventing the wheel to derive a calculated value, put functions to work for you, and you’ll excel with Monarch.</p>
<p>&#8212;</p>
<p>Continue your commitment to Become a Better Monarch Modeler with <a href="http://excelwithmonarch.com/tips/monarchs-address-block-wizard" title="Monarch's address block wizard">Part 11</a> of the series, or review <a href="http://excelwithmonarch.com/tips/mastering-monarch%E2%80%99s-table-window-controls-and-layout" title="Mastering Monarch's Table window controls and layout">Part 9</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/employing-functions-for-specialized-tasks/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get Access to Additional Functions</title>
		<link>http://ExcelWithMonarch.com/functions/get-access-to-additional-functions</link>
		<comments>http://ExcelWithMonarch.com/functions/get-access-to-additional-functions#comments</comments>
		<pubDate>Thu, 26 Mar 2009 05:07:32 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Combining Data Sources]]></category>
		<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/get-access-to-additional-functions</guid>
		<description><![CDATA[In a prior post, I wrote about how Monarch outperformed Access as a report writer. Today the wind has blown the other way, and we’ll focus on how Access can provide additional functionality for your Monarch models. Monarch user Diane recently asked whether a logarithmic function was available in the software. Unfortunately it is not, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In a prior post, I wrote about how <a href="http://excelwithmonarch.com/databases/monarch-beats-access-at-its-own-game">Monarch outperformed Access</a> as a report writer. Today the wind has blown the other way, and we’ll focus on how Access can provide additional functionality for your Monarch models.</p>
<p>Monarch user Diane recently asked whether a logarithmic function was available in the software. Unfortunately it is not, so the hunt was on to find an alternate solution.</p>
<p>Initially I thought that she might be able to export values out to Excel and then apply Log functions to the data, and would then finally be able to import back into Monarch with an <a href="http://excelwithmonarch.com/calcfield/comparing-monarchs-internal-and-external-lookups">external lookup</a>. But the large data sets would prevent that with Excel 2003.</p>
<p>And that was a good thing, because it forced me to look for another option, and what I devised was, I believe, a better solution.</p>
<p>It occurred to me from my SQL programming efforts that many functions can be called in the process of querying the database, so I checked to see if the Log function could be called in an Access query. It could!</p>
<p>This small act can let you effectively add to Monarch’s abilities pretty easily. I described the steps to take in detail on <a href="http://www.monarchforums.com/showpost.php?p=11756&amp;postcount=6">Datawatch’s forum</a>, but here is the general concept.</p>
<p>First, we need to create the initial Access database in which to build our custom query, so export the table records to a new Access database. For this type of need, there’s a good chance the query will be used regularly, so be sure to setup a Project Export with Monarch.</p>
<p>There’s an important step while defining the export, and that is to tell Monarch not to overwrite the file when exporting, but instead to add data to the database. Why is that? If Monarch overwrites the Access database, it will destroy the custom query that will be defined in the next major step. Finish defining the database definition by electing to overwrite the destination table within the database and running the export.</p>
<p>Now start up Access and open the newly created database and create a new query with the query wizard. Add all of the fields that you need to the query and select the default of Detail and finish the query. Open your new query and under the View menu select SQL View. You’ll see something like</p>
<p>SELECT Table.Field1, Table.Field2<br />
FROM Table;</p>
<p>This is where you can define a new field using a function. Just add a little bit to the SQL that Access creates.</p>
<p>SELECT Table.Field1, Table.Field2, Log(Table.Field1)/Log(10) AS LogValue<br />
FROM Table;</p>
<p>The “AS” lets you name the field as you desire, instead of letting Access assign a name for you.</p>
<p>Saving the query stores your customization in the database and this addition to the database will be used by Monarch Pro. This is the next step of the process.</p>
<p>Back in the Monarch model, create a new external lookup. Select the Access database, and instead of selecting the table that was exported from Monarch, select the new query.</p>
<p>When Monarch runs the query, the SQL statement calculates the function using the values in the table, and the results of those calculations are brought into Monarch.</p>
<p>OK, interesting enough, but what can be done with it?</p>
<p>There are a number of <a href="http://www.webcheatsheet.com/SQL/access_functions/" target="_blank">functions that are available in Access</a> that aren’t built into Monarch. Which one can you use to your advantage to help you excel with Monarch?</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/get-access-to-additional-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Batman Would Love Monarch</title>
		<link>http://ExcelWithMonarch.com/functions/batman-would-love-monarch</link>
		<comments>http://ExcelWithMonarch.com/functions/batman-would-love-monarch#comments</comments>
		<pubDate>Fri, 18 Jul 2008 01:00:13 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/batman-would-love-monarch</guid>
		<description><![CDATA[I always found Batman to be the cleverest of the famous super heroes. He always had the coolest gadgets, had designed them himself, and always had them at the ready. Batman doesn&#8217;t have to be the only one building cool and useful tools. One of the best ways for you to excel with Monarch is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I always found Batman to be the cleverest of the famous super heroes. He always had the coolest gadgets, had designed them himself, and always had them at the ready.</p>
<p>Batman doesn&#8217;t have to be the only one building cool and useful tools. One of the best ways for you to excel with Monarch is by building what Monarch calls &#8220;<a href="http://excelwithmonarch.com/functions/an-introduction-to-monarch%E2%80%99s-custom-functions" target="_blank">user defined functions</a>&#8220;.</p>
<p>In and of themselves, they&#8217;re a fantastic feature of the product. But when you share your expertise with them with the rest of your group, alleviating them from the nitty-gritty details, you&#8217;ll be their hero.</p>
<p>All you need to do is get comfortable with Monarch&#8217;s linked objects features, available in V9. Being a fairly extensive topic, Datawatch felt that it was such a significant addition Monarch that it warranted separate documentation. You&#8217;ll find that there&#8217;s a very nicely written guide (a PDF file) available when you install Monarch.</p>
<p>Once you&#8217;re up to speed, give your fellow Monarch users a quick tour of how they can benefit from your hard work by instructing them how they can simply import the various Monarch objects that you&#8217;ve created into their models, or by creating links to your work in their models.</p>
<h3>To The Bat Cave!</h3>
<p>Be a super hero to your organization. Load up your utility belt with high powered custom functions, make them accessible to all, and you and your group will excel with Monarch.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/batman-would-love-monarch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monarch&#8217;s Conversion Functions</title>
		<link>http://ExcelWithMonarch.com/functions/monarchs-conversion-functions</link>
		<comments>http://ExcelWithMonarch.com/functions/monarchs-conversion-functions#comments</comments>
		<pubDate>Fri, 20 Jun 2008 06:09:43 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/monarchs-conversion-functions</guid>
		<description><![CDATA[Over the past week, we&#8217;ve been discussing Monarch various functions that you can use in your calculated fields and filters. So far, we&#8217;ve covered date functions, the special report functions that return data related to the origin of the data (as opposed to the data within the report), and we even had a quick look [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Over the past week, we&#8217;ve been discussing Monarch various functions that you can use in your <a href="http://excelwithmonarch.com/calcfield/monarchs-calculated-fields">calculated fields</a> and <a href="http://excelwithmonarch.com/filtering/filtering-data-with-monarch">filters</a>. So far, we&#8217;ve covered <a href="http://excelwithmonarch.com/functions/conquering-date-problems-in-monarch">date</a> functions, the special <a href="http://excelwithmonarch.com/functions/exploring-monarchs-report-functions">report functions</a> that return data related to the origin of the data (as opposed to the data within the report), and we even had a quick look at the set of <a href="http://excelwithmonarch.com/functions/monarchs-special-functions">special functions</a> that Monarch offers to check data values, generate random numbers (often used in <a href="http://excelwithmonarch.com/tips/required-software-for-auditors">auditing</a>) and its implementation of the &#8220;if then else&#8221; type of function seen in many software packages.</p>
<h3>Accurate Data: The Final Frontier</h3>
<p>It&#8217;s tough enough sometimes just getting the data we need properly captured from within our reports and other source. But sometimes our data isn&#8217;t always exactly what we want it to be, at least in terms of type, and since some manipulations are easier to perform than one type than another, today we&#8217;ll examine the functions that allow us to convert from one <a href="http://excelwithmonarch.com/calcfield/an-introduction-to-monarch%e2%80%99s-field-types">data type</a> to another.</p>
<h3>Asc()</h3>
<p>Every single character, number and symbol that you can type in a document and view on your computer (and some that you can&#8217;t see too), are stored internally by the computer as values. &#8220;Asc&#8221; is short for ASCII, an acronym for what essentially is referred to as the standard way that your computer converts characters to values to store and use in its memory. There are countless web pages (<a href="http://www.asciitable.com/">even entire sites</a>) that can inform you about the ASCII values (or &#8220;ASCII table&#8221;), but one of the cleaner, more concise ones available just happens to be on the <a href="http://www.datawatch.com/downloads/ascii-chart.txt">Datawatch support site</a>.</p>
<p>One additional benefit of the table on the Datawatch page is that at the bottom you&#8217;ll find how all of this relates to the Monarch Utility program, and may well be the only official documentation on how to perform search and replace tasks with the Utility.</p>
<p>So what&#8217;s the big deal with converting letters and symbols and such into a decimal number, and what would you ever possibly need this for with Monarch? Have you ever seen odd square boxes, or symbols that don&#8217;t seem to belong, in a data file? With the Asc() function you can determine exactly what that thing is, and deal with it properly yourself, or tell the supplier of the data file exactly what bad data is being inserted incorrectly into your report.</p>
<h3>CharToSeconds()</h3>
<p>This function converts a string that looks like a time, like &#8220;10:09:36&#8243; into the number of seconds since midnight, a numeric value.</p>
<h3>Chr()</h3>
<p>Chr() is the opposite of the Asc() function. Where Asc(&#8220;A&#8221;) returns 65, Chr(65) returns &#8220;A&#8221;. Chr() is great for inserting symbols like a carriage return: Chr(13).</p>
<h3>CtoD()</h3>
<p>This indispensable gem has been discussed on this site more than once already, to convert a Character field to a Date field.</p>
<h3>DateToJulian()</h3>
<p>This function converts a regular date field to a <a href="http://en.wikipedia.org/wiki/Julian_day">Julian date</a> value. Some ERP systems built with Sybase or JD Edwards software seem to use Julian dates, or variants of them.</p>
<h3>DtoC()</h3>
<p>Opposites are at work again, this time reversing the CtoD() function, and returning a character string that looks like a date.</p>
<h3>JulianToDate()</h3>
<p>Anyone care guess what this does? <img src='http://ExcelWithMonarch.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h3>SecondsToChar()</h3>
<p>Yet another opposite function, this time converting the number of seconds from midnight into a character string that looks like a proper time.</p>
<h3>Str()</h3>
<p>This function converts a numeric value into a character string. The function has a few optional arguments, which allow you to specify how long you want the string to be, the number of decimal place to round the value, and a character with which to optionally fill up any remaining space in the string.</p>
<h3>Val()</h3>
<p>The final function of this set is also the final opposite; this time converting a character string that looks like a number into a true numeric value.</p>
<h3>Universal Translator</h3>
<p>I often refer to Monarch, when introducing it to those unfamiliar with it, as a type of universal data translator; able to almost effortlessly convert data from one format or location to another. These functions really do extend the analogy, easily changing and translating raw data from one presentation into another. Use them wisely and you&#8217;ll live long and prosper, or at least excel with Monarch.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/monarchs-conversion-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monarch&#8217;s Special Functions</title>
		<link>http://ExcelWithMonarch.com/functions/monarchs-special-functions</link>
		<comments>http://ExcelWithMonarch.com/functions/monarchs-special-functions#comments</comments>
		<pubDate>Tue, 17 Jun 2008 04:48:34 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/monarchs-special-functions</guid>
		<description><![CDATA[Over the last couple of posts, we&#8217;ve examined some of Monarch functions. Since we&#8217;re on a bit of a roll, let&#8217;s carry on with the topic. Today we&#8217;ll look at a special category of functions, known as, well, special functions. There aren&#8217;t too many, so this might be pretty quick. If() Just about every application [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Over the <a href="http://excelwithmonarch.com/functions/exploring-monarchs-report-functions">last</a> <a href="http://excelwithmonarch.com/functions/conquering-date-problems-in-monarch">couple</a> of posts, we&#8217;ve examined some of Monarch functions. Since we&#8217;re on a bit of a roll, let&#8217;s carry on with the topic.</p>
<p>Today we&#8217;ll look at a special category of functions, known as, well, special functions. There aren&#8217;t too many, so this might be pretty quick.</p>
<h3>If()</h3>
<p>Just about every application that allows you to do any kind of analysis has an &#8220;If&#8221; function, and Monarch is no different. The format is If(condition, result if true, result if false). Incredibly simple, but simultaneously really powerful. If() doesn&#8217;t care what kind of data you use for the condition test, as long as it can properly resolve the condition. That means that these conditions are valid, and can be used in an If() function:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MyDateField &lt; {2008-12-31}</div></div>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ProfitAmount &gt; 999</div></div>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Left(FullName,3) = &quot;Mr.&quot;</div></div>
<p>but these are not valid in an If() function:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MyDateField &lt; &quot;12/31/2008&quot;</div></div>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ProfitAmount = &quot;Mr. Bob Smith&quot;</div></div>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Left(FullName,3) &gt; 999</div></div>
<p>As well, you can include, or &#8220;nest&#8221; multiple If() functions together in one expression, such as:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">If(ProfitAmount&gt;0,If(ProfitAmount&gt;500,&quot;Great&quot;,&quot;Good&quot;),&quot;Poor&quot;)</div></div>
<p>In this example, a ProfitAmount of 300 would be &#8220;Good&#8221;, 800 would be &#8220;Great&#8221;, and -100, a loss, would be &#8220;Poor&#8221;.</p>
<h3>IsEmpty()</h3>
<p>The IsEmpty() function tests to see if a field is empty. I suspect that this is really meant to test character or memo type fields, but Monarch&#8217;s online help doesn&#8217;t specify that requirement. The function returns a numeric value, either one if the test field is empty, or zero if it isn&#8217;t. So if the field MiddleName is blank,</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">IsEmpty(MiddleName)</div></div>
<p>would return a one, but if the field held the value &#8220;Stephen&#8221;, it would return a zero. Close to the IsEmpty() function is&#8230;</p>
<h3>IsNull()</h3>
<p>Where IsEmpty() tests for (I suspect) an empty string, IsNull() tests for absolutely nothing. That is, there&#8217;s no value in the field at all. Since IsEmpty works well for character or memo type fields, I would use IsNull() exclusively on numeric or date fields. And just like IsEmpty(), IsNull returns a one when the test is true, and a zero when the test is false.</p>
<p>So if your report has a field where a date is optional for a specific record or transaction type, you can test to see if a date exists for a record before you do a calculation with that date. Let&#8217;s suppose that you need to calculate a due date of 30 days after an invoice date, when an invoice date exists, that is. The formula would be:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">If(IsNull(InvDate,CtoD(&quot;&quot;,&quot;m/d/y&quot;),InvDate+30)</div></div>
<p>CtoD(&#8220;&#8221;,&#8221;m/d/y&#8221;) properly returns a null value to a date type field.</p>
<p>The last two functions in the &#8220;special&#8221; category are:</p>
<h3>Rand() and RandEx()</h3>
<p>They both generate a random integer value. Rand() gives you a value between zero and 32,767. RandEx() goes considerably higher; from zero to 4,294,967,295. Random number generators have many practical purposes, but honestly, I rarely use them. In fact, I use Rand() from time to time for creating data from scratch in Excel, but I really don&#8217;t recall having ever used either of the random functions in Monarch.</p>
<h3>That&#8217;s a Wrap</h3>
<p>As I said at the top, the list of functions in Monarch&#8217;s &#8220;special&#8221; category of is pretty short. But mastering these functions, especially If() in it&#8217;s multiple instance version, can be key in your ability to excel with Monarch.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/monarchs-special-functions/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Exploring Monarch&#8217;s Report Functions</title>
		<link>http://ExcelWithMonarch.com/functions/exploring-monarchs-report-functions</link>
		<comments>http://ExcelWithMonarch.com/functions/exploring-monarchs-report-functions#comments</comments>
		<pubDate>Mon, 16 Jun 2008 05:51:23 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/exploring-monarchs-report-functions</guid>
		<description><![CDATA[Last week we touched on a couple of useful conversion functions that are available to us in Monarch. Today we&#8217;ll continue looking at functions; this time focusing on one of the smaller function categories, that of the &#8220;report&#8221; functions. Report functions are those which give us data related to the actual report file in use, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Last week we touched on a couple of <a href="http://excelwithmonarch.com/functions/conquering-date-problems-in-monarch">useful conversion functions</a> that are available to us in Monarch. Today we&#8217;ll continue looking at functions; this time focusing on one of the smaller function categories, that of the &#8220;report&#8221; functions. Report functions are those which give us data related to the actual report file in use, not the direct data included in the report itself.</p>
<h3>File()</h3>
<p>The File() function returns the full path and filename of the report from which your record was extracted. While this is a pretty straightforward function, and you might wonder why you would ever need to include text like &#8220;D:\Reports\Shipping Report.txt&#8221; in your data, there are times when I find it absolutely indispensible.</p>
<p>I like to keep my historical data handy, effectively creating mini data warehouses. I like to create topic folders for these mini data warehouses. For instance, I might have an AR folder and a Shipping folder. Within each folder I&#8217;ll store reports representing the monthly activity for that topic, as this makes it much easier to extract periodic data which can easily analyzed graphically.</p>
<p>When you store many instances of a report within a topic folder, you need to organize your reports a little. My convention is to start with the topic name, like Shipping, and always include a three letter month and a four digit year, along the file type extension, like &#8220;Shipping Jun 2008.prn&#8221;. At a glance I know what the file is, and for what period the report was run. Additionally, your report may or may not include data that you can extract to determine a period. And if that&#8217;s not troublesome enough, you may share my situation, in which the date that appears in the report isn&#8217;t actually properly representative of the actual fiscal period.</p>
<p>So my solution is to extract the period from the filename. Since I know that I will always use a &#8220;.prn&#8221; (or &#8220;.txt&#8221; extension, I know that the last four characters in the filename will be an extension. Further I know that I&#8217;ll always use a &#8220;mmm yyyy&#8221; structure just before the extension. That&#8217;s seven characters, plus the four for the extension, for a total of 11 characters. So using a Right(File(),12) on &#8220;D:\ReportsShipping\Shipping Jun 2008.txt&#8221; will give me &#8220;Jun 2008.txt&#8221; regardless of the category name. Changing that slightly to Left(Right(File(),12),3), I get &#8220;Jun&#8221;. To get the year, Left(Right(File(),8),4) will return &#8220;2008&#8243;. Put it together with a &#8220;/1/&#8221; string in the middle, and you get Left(Right(File(),12),3) + &#8220;/1/&#8221; + Left(Right(File(),8),4).</p>
<p>Finally, using all of that as the input for a CtoD function, like:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CtoD(Left(Right(File(),12),3)+&quot;/1/&quot;+Left(Right(File(),8),4),&quot;m/d/y&quot;)</div></div>
<p>and you get a valid period in your data that you&#8217;ve derived from your filename.</p>
<h3>ID()</h3>
<p>I find ID() to be a bit of an odd one. It returns the number of the report from which your record was extracted. As you open multiple reports in Monarch simultaneously, Monarch assigns a value of 1 to the first report opened, and adds one to each successive report. In all these years, I&#8217;ve yet to find a use for this. Have you?</p>
<h3>Line()</h3>
<p>The Line() function returns the line on which this record appears in the report. You can get some odd looking, yet accurate, values with Line() when you&#8217;re using filters.</p>
<h3>Page()</h3>
<p>Similar to Line(), Page() returns the page number of the report from which the record was extracted. From time to time I&#8217;ve taken advantage of the Page() function when building filters. Some times data appears on the first page of a report that gets captured by an extraction template (based on the trap created in the template), but I didn&#8217;t necessarily want that part of the data set. Rather than playing with the trap to somehow exclude that bit, I&#8217;ll use the Page() function and filter out all the page one data (Page()&lt;&gt;1).</p>
<h3>Recno()</h3>
<p>Recno() returns the sequential detail record number, starting at 1. If your data set has 100 records, and your filter only returns three records, you may see 7, 43 and 89 as the only values returned.</p>
<h3>Rowno()</h3>
<p>Rowno() is similar to results of the Recno() function for some reports, but the notable, and useful, exception is that Rowno() isn&#8217;t affected by filters. If your filter returns 100 records, Rowno() will return 1 through 100.</p>
<h3>It&#8217;s the Function of the Function</h3>
<p>The importance of the various functions available isn&#8217;t so much what the function actually does, in and of itself, but more how you can use it creatively to achieve something that isn&#8217;t immediately obvious. Use your imagination and a little experimentation, and you&#8217;ll excel with Monarch.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/exploring-monarchs-report-functions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conquering Date Problems in Monarch</title>
		<link>http://ExcelWithMonarch.com/functions/conquering-date-problems-in-monarch</link>
		<comments>http://ExcelWithMonarch.com/functions/conquering-date-problems-in-monarch#comments</comments>
		<pubDate>Fri, 13 Jun 2008 04:15:38 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/functions/conquering-date-problems-in-monarch</guid>
		<description><![CDATA[Yesterday I received a message from a reader asking about how she could resolve a challenge with extracting dates from her report. The problem was that the date in the report appeared in the form of 01-Oct-07, and she wanted 10-01-2007. She&#8217;d been trying to use, correctly, the CtoD function, but kept getting null values [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Yesterday I received a message from a reader asking about how she could resolve a challenge with extracting dates from her report.</p>
<p>The problem was that the date in the report appeared in the form of 01-Oct-07, and she wanted 10-01-2007. She&#8217;d been trying to use, correctly, the CtoD function, but kept getting null values no matter what she did.</p>
<p>I supposed that she was really close to a possible solution. If she was indeed using CtoD(RptDate,&#8221;m/d/y&#8221;), where RptDate is a character field, then Monarch would indeed return a null value. A subtle change to CtoD(RptDate,&#8221;d/m/y&#8221;) yields 10/1/2007.</p>
<p>The date is correct, but that&#8217;s not the exact format she wanted. To get that, with leading zeros for both the month and the day numbers, it takes a much more complex formula:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Right(&quot;00&quot;+Trim(Str(Month(CtoD(RptDate,&quot;d/m/y&quot;)))),2) + &quot;-&quot; + Right(&quot;00&quot;+Trim(Str(Day(CtoD(RptDate,&quot;d/m/y&quot;)))),2) + &quot;-&quot; + Trim(Str(Year(CtoD(RptDate,&quot;d/m/y&quot;))))</div></div>
<p>This formula uses the basic date conversion formula as above, but extracts out the day, month and year values, adds leading zeros with some string conversion and manipulation functions, and ties them all together with a couple of dashes.</p>
<p>Just a few minutes later, a member of Datawatch&#8217;s online <a href="http://www.monarchforums.com/index.php">Monarch Forum</a> asked another date related question. In this case, the character date appeared as mmm-yyyy, and once again, CtoD was returning null values.</p>
<p>CtoD needs three values in order to convert to a date: day, month, and year. If you&#8217;re missing any of them, CtoD will fail in every case. This means that you&#8217;ve got to supply what&#8217;s missing yourself to make it work.</p>
<p>Since the report itself didn&#8217;t include a day value, then the day number that we supply the CtoD isn&#8217;t really important; it&#8217;s just an arbitrary value to make the function work. To make sure that your formula works for every month, you could pick the 15th or the 28th, but in situations like this you&#8217;re probably better off with choosing the first of the month.</p>
<p>A possible formula to resolve this challenge is as follows:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CtoD(Left(RptDate,3)+&quot;/01/&quot;+Right(RptDate,4),&quot;m/d/y&quot;)</div></div>
<p>Again, string manipulation functions play a role as we pull off the left and right sides of the report date, and add our own day number in the middle, and the &#8220;m/d/y&#8221; tells Monarch what format to expect in our final string.</p>
<h3>Today&#8217;s the Day</h3>
<p>Monarch includes quite a number of date related functions, and we&#8217;re sure to explore them further in the future, but the thing to keep in mind is that sometimes they need a little help from you to get you the right results. Do some more <a href="http://excelwithmonarch.com/tips/no-news-is-good-news">homework</a> today on Monarch&#8217;s functions and you&#8217;ll soon feel that you can excel with Monarch.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/functions/conquering-date-problems-in-monarch/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Handling Floating or Missing Values with Monarch</title>
		<link>http://ExcelWithMonarch.com/calcfield/handling-floating-or-missing-values-with-monarch</link>
		<comments>http://ExcelWithMonarch.com/calcfield/handling-floating-or-missing-values-with-monarch#comments</comments>
		<pubDate>Thu, 13 Mar 2008 19:20:39 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[Calculated Fields]]></category>
		<category><![CDATA[Extraction Templates]]></category>
		<category><![CDATA[Functions]]></category>

		<guid isPermaLink="false">http://ExcelWithMonarch.com/calcfield/handling-floating-or-missing-values-with-monarch</guid>
		<description><![CDATA[From time to time you may run into a report designed by some renegade programmer who thought that having values shift positions from line to line on the report was actually a good idea. Additionally, maybe she thought that, rather than display zero values, it would be best if the report simply doesn&#8217;t display anything [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>From time to time you may run into a report designed by some renegade programmer who thought that having values shift positions from line to line on the report was actually a good idea. Additionally, maybe she thought that, rather than display zero values, it would be best if the report simply doesn&#8217;t display anything at all for that field.When it comes to making it easy for the Monarch modeler, nothing could be further from the truth. We like predictable (in that we know that a value &#8211; something! &#8211; will appear where it should) and nicely aligned values.</p>
<h3>When the Floating Trap Isn&#8217;t Enough</h3>
<p>Sometimes you can handle these situations nicely with the floating trap feature. But sometimes there just too many problems with the line for Monarch to make sense out of it.</p>
<p>Fear not! All is not lost. But it will take a little extra work to get the results you need.</p>
<p>Recently a user of Datawatch&#8217;s Monarch Forum posted this snippet from his report:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NET ACCT TYPE INS BAD DEBT CLIENT ------------------------------------AGING------------------------------------<br />
OPEN BILLED RCPTS ADJS REFS CHANGE XFERS XFERS XFERS CLOSE 0-30 31-60 61-90 91-120 121-150 151-180 TURN OVER<br />
BC TOTAL<br />
549428.75 424468.29 -173614.33 -300985.92 0.00 -11869.87 -44360.03 0.00 0.00 443066.89 321047.56 39894.32 34844.97 -32766.67 -179.92 80226.63 -0<br />
MCR TOTAL<br />
4356874.49 3887773.75 -1447498.42 -2542241.09 0.00 0.00 -130712.26 0.00 0.00 4124196.47 3185408.90 260237.40 154257.40 157188.27 175734.26 191370.24 -0<br />
WC TOTAL<br />
64420.13 -19328.27 -14944.49 0.00 30147.37 18500.13 11647.24 0<br />
GRAND TOTAL<br />
13174622.19 6984031.36 -2854893.59 -4196472.77 12526.20 -7605.05</div></div>
<p>Hmm. This sample doesn&#8217;t post very well here. Rather than spending my time fighting with it, I&#8217;ll point out <a href="http://www.monarchforums.com/showthread.php?p=9181#post9181" title="report sample with floating and missing values">the original post with the sample</a>.</p>
<p>You can see that there are both floating and missing values in the sample. The best of both worlds, as it were&#8230;</p>
<p>The solution involves knowing how many fields you expect to see on the line, and introducing a device &#8211; an unusual character, anything that you wouldn&#8217;t expect to normally see in the report &#8211; to allow for extracting the values easily with one of Monarch useful functions. This character will allow us to split up the fields later on.</p>
<p>The first step is to capture the entire line as a single field, rather than even trying to get this field and that field at the outset. We&#8217;ll name that field &#8220;A&#8221; as it really doesn&#8217;t matter what we call it.</p>
<p>Next, we insert our splitting character. Field B has the expression:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Replace(A,Space(11),&quot;|&quot;)</div></div>
<p>In field A, any occurance of 11 consecutive spaces will be replaced with a single vertical bar, otherwise known as a pipe character. Why 11 spaces? Any time there are 11 spaces in this sample, we know that a needed field is completely missing. You&#8217;ll need to carefully assess your particular report to determine this number.</p>
<p>Next, we clean things up a little bit more. We&#8217;ll still have a number of repeated spaces, so determining exactly where our fields are is still a bit of a challenge. Now we eliminate the repeated space, replacing them with just a single space. Field C has the simple expression:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">InTrim(B)</div></div>
<p>Now it&#8217;s a simple matter to replace all of those unwanted spaces with the splitting device (our delimiter). Field D has the expression:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Replace(C,&quot; &quot;,&quot;|&quot;)</div></div>
<h3>Be a Data Chef: Slice and Dice!</h3>
<p>Finally we have string with nothing but values and pipe characters. Monarch can dissect values from such a string easily. Our first field that we really want from the report, Open, is a Numeric field and has the expression:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Val(LSplit(D,40,&quot;|&quot;,1)</div></div>
<p>Monarch will split field D into 40 sections, based on the location of the pipe characters. You can always supply a higher number of sections than you really need. Monarch doesn&#8217;t care. Just make sure that you&#8217;ve supplied enough. The exact number is fine if you want to count the fields.</p>
<p>Once Monarch extracts that bit of the original field, it&#8217;s still a character string, so we use the Val() function to convert it to a number, as that&#8217;s expected by the field type we defined.</p>
<p>The next field, NetBilled, simply increases the last value in the last formula by one, like this:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Val(LSplit(D,40,&quot;|&quot;,2)</div></div>
<p>By spending a few minutes creating the remaining fields (use the Duplicate button), you&#8217;ll have tamed this beast of a report that you thought was not possible to model with Monarch.</p>
<p>The process could be streamlined a fair bit by combining the separate calculated fields. Instead of using the various fields B, C, and D as presented above, you could establish field B as:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Replace(InTrim(Replace(A,Space(11),&quot;|&quot;)),&quot; &quot;,&quot;|&quot;)</div></div>
<p>Then your final fields would use:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Val(LSplit(B,40,&quot;|&quot;,1)</div></div>
<p>Additionally, by introducing just a couple more fields, you could make this a portable solution for any report that is giving you the same problem, and the only work you need to do to model for that particular report would be to define the final values fields themselves.</p>
<p>By using runtime parameter calculated fields for the number of spaces (SpaceCount), the delimiter character (NewDelimiter), and maybe the number of fields if you really want to be picky, the final expression would be:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Replace(InTrim(Replace(A,Space(SpaceCount),NewDelimiter)),&quot; &quot;,NewDelimiter)</div></div>
<h3>Alternatively, Let Excel Split The Fields</h3>
<p>Building the various numeric fields that split our B field (with all of the pipe characters), might be avoidable. And you can achieve with the same end result too!</p>
<p>Just export the B field, and any other fields you&#8217;ve appended, to an Excel file or text file, then import that file into Excel and use Excel&#8217;s Text to Columns feature, specifying the pipe character as the Other delimiter. Excel will put each field value in its own cell properly across the columns.</p>
<p>Now that&#8217;s using Excel with Monarch!</p>
<h3>Powerful Data Mining Technology for Everyone</h3>
<p>It&#8217;s easy to take your tools for granted, especially after you&#8217;ve been using those tools for awhile. But every time I see a really oddly designed report, and someone has created a Monarch model for it, I&#8217;m reminded of just how good Monarch really is.</p>
<p>Combining many of Monarch&#8217;s features, and perhaps using them in unusual or even possibly an unintended manner, will really let you excel with Monarch.</p>
]]></content:encoded>
			<wfw:commentRss>http://ExcelWithMonarch.com/calcfield/handling-floating-or-missing-values-with-monarch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

