Monday, November 19, 2012

Financial Dimension Lookup for AX 2012

If you just took the dive into AX 2012, you may have noticed quite a change in how financial dimensions are stored.  I'm here to bring light to how to access the dimension values with the new structure so that you may use them as you did in the 4.0/2009 system.

As a review: In AX 4.0 and 2009, a business was limited to the number of financial dimensions they wanted, I believe the default amount of dimensions was 3, but additional dimensions could be purchased and was regulated by the license file provided by Microsoft when AX is purchased.  The various tables that did utilize these financial dimensions simply had a column for each dimension, namely Dimension[1], Dimension[2], Dimension[3], etc... (in SQL: Dimension, Dimension2_, Dimension3_, etc...) depending on how many dimensions your business purchased, of course.  Each one of these fields stored the actual value of the dimension right there in that table.  If you wanted to reference the name or description of that Dimension, it was easy.  AX had a Dimensions table where you could just do a Dimensions::find() and provide the dimension value stored in the above table and your DimensionCode enum type (to specify which dimension you are supplying).  Presto, upon returning the Dimensions record, you reference the Description field and you have the dimension description/name.

AX 2012 handles this quite differently...

Instead of there being a limit on the number of financial dimensions, the team at Microsoft found a way to lift that restriction and now allow for infinite dimensions.  Yahoo!  But it doesn't come for free (don't think monetarily).  The price you pay is the complexity of it.  Instead of storing each of the dimensions on a given table, their solution is to store a reference (to the related table's RecId) of a record in a centralized dimension table in a column called DefaultDimension.  This is the value that will eventually get you to your dimensions.

If you don't care about a technical data structure oversight and just want a simple solution, you can skip down to the solution below, otherwise continue reading (this is starting to feel like a Goosebumps "Give Yourself" book).

The centralized dimesion table I was referring to is DimensionAttributeValueSetItem.  The DimensionAttributeValueSet field in this table is going to be the field that DefaultDimension relates to.  For each financial dimension that is specified for a record, there will be that many records in the DimensionAttributeValueSetItem table.  There is a field called DisplayValue in this table, this is the value of the dimension!  Yahoo!  Don't get too excited yet, there are no values in this table that will tell us which financial dimensions are which.  We will need to join to DimensionAttributeValue and again to DimensionAttribute first.  From here it is tricky if you're looking to find the human-readable description in addition, depending on what kind of dimension it is, it will link to a different table.  I suggest only linking to the tables you need to.  If you have custom dimensions, you will outer join to DimensionAttributeDirCategory and DimensionFinancialTag (as shown below).  Any other types of dimensions link to various Views with a "DimAttribute" prefix but also must be linked to the current company that is selected.  I've included an example of linking to Customer and Project dimensions.  Below you will find a SQL query which will define the join criteria.
SELECT davsi.DisplayValue, da.Name, dft.Description, dact.Name, dapt.Name
FROM DimensionAttributeValueSetItem davsi
JOIN DimensionAttributeValue dav
    ON dav.RecId = davsi.DimensionAttributeValue
JOIN DimensionAttribute da
    ON da.RecId = dav.DimensionAttribute
--Custom dimensions
LEFT JOIN DimensionAttributeDirCategory dadc
    ON dadc.DimensionAttribute = da.RecId
LEFT JOIN DimensionFinancialTag dft
    ON dft.FinancialTagCategory = dadc.DirCategory
AND dft.RecId = dav.EntityInstance
--Customer dimension
LEFT JOIN DimAttributeCustTable dact
    ON dact.Value = davsi.DisplayValue
    AND dact.RecId = dav.EntityInstance
    AND dact.DataAreaId = 'dat'
--Project dimension
LEFT JOIN DimAttributeProjTable dapt
    ON dapt.Value = davsi.DisplayValue
    AND dapt.RecId = dav.EntityInstance
    AND dapt.DataAreaId = 'dat'
WHERE davsi.DimensionAttributeValueSet = '5637144584'
--where '5637144584' is the DefaultDimension reference value
The interesting part to note about the above query is the da.Name field.  This is the AX 2012 equivalent to the DimensionCode Enum, only AX 2012 doesn't use Enums for dimensions (because Enums cannot (and shouldn't) be created dynamically by your end users, but financial dimensions now can be and are meant to be defined by your end users).  So, when coding, you will either need to hard code these dimension names, or create your own Enum or Macro that you must manage separately.  I don't like it either but it is what it is.

SOLUTION

I have developed a couple of helper methods that simply the retrieval of dimension data.  These can be included in a helper class and referenced to as static methods are normally, but I recommend including these in your Global class, then you can just call the method directly.  I have 2 methods: dimValue() and dimDesc(), they return the value and description, respectively.  Code and usage is below:
//Usage for dimValue() and dimDesc()
static void JobDimensionUsage(Args _args)
{
    SalesLine       sl;

    DimensionValue  value;
    Description     desc;
    ;
    select firstonly sl;

    value = dimValue(sl.DefaultDimension, 'Department');
    desc = dimDesc(sl.DefaultDimension, 'Department');

    info(strfmt("%1: %2", value, desc));
}
static DimensionValue dimValue(RefRecId _defaultDimension, Name _name)
{
    DimensionAttributeValueSetItemView  davsi;
    DimensionAttribute                  da;
    ;
    select DisplayValue from davsi
    where davsi.DimensionAttributeValueSet == _defaultDimension
    join RecId from da
    where da.RecId == davsi.DimensionAttribute
        && da.Name == _name;
 
    return davsi.DisplayValue;
}

static Description dimDesc(RefRecId _defaultDimension, Name _name)
{
    DimensionAttributeValueSetItemView  davsi;
    DimensionAttribute                  da;
    DimensionFinancialTag               dft;
    DimensionAttributeDirCategory       dadc;
    DimAttributeCustTable               dact;
    DimAttributeProjTable               dapt;
    ;
    select DimensionAttributeValueSet from davsi
    where davsi.DimensionAttributeValueSet == _defaultDimension
    join RecId from da
    where da.RecId == davsi.DimensionAttribute
        && da.Name == _name
    outer join Name from dadc
    where dadc.DimensionAttribute == da.RecId;
    outer join Description from dft
    where dft.RecId == dav.EntityInstance
        && dft.FinancialTagCategory == dadc.DirCategory
    outer join Name from dact
    where dact.RecId == dav.EntityInstance
        && dact.Value == davsi.DisplayValue
    outer join Name from dapt
    where dapt.RecId == dav.EntityInstance
        && dapt.Value == davsi.DisplayValue;
 
    return (dft.Description ? dft.Description : (dact.Name ? dact.Name : (dapt.Name ? dapt.Name : "")));
}

Friday, March 9, 2012

Increase Performance by Removing Unused Overridden Methods?

It's been in the back of my mind for quite awhile now to figure out how the kernel of Dynamics AX actually handles it's delete_from and update_recordset logic. Sometimes, the kernel decides to emit exactly one DELETE FROM query to the database versus one 'DELETE FROM table WHERE RecId = @P1' per record in the table buffer.

I found a case on PriceDiscTable (this situation is not limited to just this object), a noticeably large table especially for our business, where I noticed multiple DELETE FROM statements getting emitted to the database, taking a very long time to complete a daily task our business runs. I looked at the table and noticed that the delete() method on the table was indeed overridden, but upon investigating the details of the method, only super() was getting called inside (along with some commented out code that we used in the past and plan to use in the future, but that's beside the point).

I removed the method as there really is no functional difference in just leaving it hidden (even though I know the reason why we wanted the commented code there, we didn't want to lose it). Lo and behold, our daily task now emits one single DELETE FROM with the criteria we specified in the WHERE clause.

One would think that the kernel would notice and see that the compiled version of the overridden delete() method with just the super() call is identical to the default "hidden" delete() method and handle them the same. But, we've been duped again. We'll have to store the commented out code we had in there somewhere else even though it would've been much more convenient to just keep in where it was.
As a side note, having at least one Delete Action on your table object will also force the kernel to emit multiple DELETE FROM queries. Removing them will tell the kernel that it doesn't have to perform a row-by-row operation and can emit the DELETE FROM in one statement.

And as (Joris de Gruyter of Dynamics AX Musings) has graciously pointed out in a comment, having database logging or alerts enabled on your table and/or having any MEMO fields on that table will also force a multiple DELETE FROM, who knew?

Friday, February 17, 2012

Missing Enums in SRSAnalysisEnums

Forenote: If you are using 2012, read this post.  There is a more robust way to access enums in AX 2012.

If your business operates like any would and has the need to report on data from custom functionality then you might find this post useful.  In creating custom functionality we often have the need to create new custom Enums and store the values in a custom table.  Doing so works just fine inside the Dynamics circle.  However, if you use a separate reporting engine outside of Dynamics, like SSRS, to render your reports, you will find that your users will not understand what a ShipStatus of 2 is, and let's be serious, your proposed solution to hard code your enum labels in your report is a poor strategy.

Microsoft was nice enough to create some tables to store enum values and labels for some of these enums.  These are located in two tables, namely, SRSAnalysisEnums and SRSModelEntityCache.  But, like I mentioned earlier, there are only SOME enums in these tables.  For a long time it was mysterious to me why it was this way, but after some digging in and a few "Ah ha!" moments later I figured it out.  It also introduced me to another unknown area of Dynamics.

Today, we're going to learn about Perspectives.  It's an object in the AOT under Data Dictionary.  Perspecitves in Dynamics are a poor attempt to mimic the functionality of a database cube.  It's not as flexible as a real cube and not very customizable.  If you expand the Perspectives node, you'll see a Perspective object for each Module.  Each of these perspectives has a list of tables.  Any enums in these tables listed under a perspective are the enums that show up in the SRS tables.  To get your new enums to show up you just need to have your table included in one of these perspectives or create your own, but try to put your table in the most relevant module, pertaining to the data that's stored in the table.

Note: If your table is already in these perspectives, read ahead.

Now, putting the table in the perspective alone won't put your enums in the table.  You also have to update the model so the SRS tables get populated correctly.  The way to do this is Tools->Reporting tools->Update models.  You can choose to update all languages or just one, as you feel is necessary for your business.  Running this will take awhile, but when it is finished, you will now see your new enums show up in the SRS tables.  Here's a script that will get your enum labels from a value:
SELECT ae.EnumItemName
FROM SRSModelEntityCache ec
JOIN SRSAnalysisEnums ae
    ON ae.EnumId = ec.EntityId
WHERE ec.PhysicalName = 'BaseEnum_ShipStatus'
    AND ae.EnumItemValue = 2

Thursday, February 9, 2012

Kernel Function Madness: any2str()

I'm a developer.  I'd treat this function as any would.  Here we have a function called any2str and takes in an anytype object and returns a string representation.  That's great because I have a dynamically changing anytype object that could be an integer one time and a date the next.  I also need to get a string representation of each type to I can put the values into the same column of a table to report on later.  So like any developer would do you code up your logic and write:
table.stringField = any2str(dynamicObject);
Sweet.  Everything compiles, let's continue writing code.
...
***Days pass***
...
Ok, time to run a test.  What?  Run-time error?  Method is expecting object of type string?  Wait, what line is it talking about?

For a moment I refused to believe that someone wouldn't have been so stupid to code up this method to expect only strings to be passed in.  And even after I realized that was the truth, I still couldn't believe it.  Yes, the method does in fact take in an anytype.  However, the method only works if that anytype is of type string.  So, instead of using the intuitive knowledge us developers have been taught to use, we have to now second guess every kernel function we call into no matter how we much "know" (think) how a method should work.  We've been duped, we've been given a useless str2str() method.

The workaround is below.  Use this as a local function (or as a method in the Global class to make a global method) inside the methods you often would use any2str(), that is, before understanding what the method really does.
str theRealAny2str(anytype _val)
{
    switch (typeof(_val))
    {
        case Types::Date:
            return date2str(any2date(_val), 213, 2, -1, 2, -1, 2);
        case Types::Enum:
            return enum2str(any2enum(_val));
        case Types::Guid:
            return guid2str(any2guid(_val));
        case Types::Int64:
            return int642str(any2int64(_val));
        case Types::Integer:
            return int2str(any2int(_val));
        case Types::Real:
            return num2str(any2real(_val), 1, 2, 1, 0);
    }
    return any2str(_val);
}

Monday, November 14, 2011

Ignore IDs During Code Compare

If any of you have done a code compare, comparing one XPO to the matching objects within the AOT, you may have noticed that in most cases the ID values of various nodes/sub-nodes don't match.  This is only partially correct, the node itself may match identically except the ID property, which doesn't cause a change in functionality anyways.  This annoyingly forces you to click through each item to verify that each node IS in fact identical.  I have developed a solution, an option to ignore these ID properties as a checkbox in the Advanced tab of the Compare form.

Let's take the Address table for example.  If we have an XPO that includes the Address table and we attempt to compare it with the object in the AOT, we will see "differences" like this:


As we can see, it shows a difference in every single field and index on the table.  What happens is when an object is exported to an XPO, it does not retain the ID values as they really don't change how it functions.  When importing from an XPO and comparing, the IDs in the XPO default to 0, thus showing the difference.

Normally this isn't a bad thing, but it gives you the feeling that there are truly differences that change the functionality.  It becomes a pain to filter through each node and double check each to see the real differences.  More often than one would think, a real difference slips by unnoticed because of the mass amount of false positives in changes, thus promoting code to Production without truly meaning to.

I proposed a solution to add an option to the SysCompareForm to ignore ID properties (as shown below).


By default, I have the checkbox checked to ignore the IDs, you may choose to change that as needed per your business's requirements.  The screenshot below shows how tidy it looks after ignoring the ID properties.



DOWNLOAD XPO HERE and Enjoy!

Bug Reported (2/27/2012): Ineffective towards EDTs and Enums, still shows the comparison.

Friday, November 4, 2011

Dynamics AX Pain Points

I've been developing in DAX for about 3 years and over those years I have generated a big written list of things that I wish would be better.  Granted, I am working in Dynamics AX 4.0, so there may have been things that have been fixed in future versions, but nonetheless I compiled a list.  Some of these are minor, some of them are big.  Some of them have workarounds, and some do not.

You ask: Why are you blogging about it?  Well, I did mention some of these written notes are years old; to be honest, it's so old the ink is starting to fade and I wanted to make an electronic copy and elaborate on them and continue to do so when I run across them.  I also hope to through time provide workarounds for these pain points.

I apologize, this is probably going to be a post that I will update from time to time, but if you have any questions, possibly about a topic that I mention there is a workaround but I haven't gotten around to explaining it, feel free to comment below and I'll do my best to either quick blog the workaround, or respond to your comment.

DAX Kernel 4.0.2503.854
DAX Application 4.0.2503.57

Issues (with Workarounds)
  • When trying to compare code from an XPO to an object in the AOT, through the Import form, right-clicking the object in the Details frame causes a Synchronize on that object, which possibly can cause a table to rebuild it's indexes
    • Workaround - It's a hack but it could save your job
  • Code compare has no option to ignore checking differences in Object IDs
    • Solution - Custom checkbox within Compare form
  • Containers are stored in the database as BLOBs, impossible to reference from outside DAX
    • Solution - I have developed two SQL user-defined functions that allow you to conpeek() outside of DAX
  • Inability to filter enums within a ComboBox control (workaround is possible, blog post soon)
  • Some enums aren't available in the SRSModelEntityCache and SRSAnalysisEnums
    • Solution - Must add your wanted Enums to a Perspective and update the model
  • Unable to update/insert data from outside DAX (Workaround possible, blog post soon)
  • Unable to reorder Data Sources within a Form after you already created them in VSS.  They only appear to reorder in the AOT but still function during runtime the same as the original order. Workaround soon - It's not pretty
  • When using VSS and creating new Jobs, the original/default name of the Job still retains as the Name property even after you change it in the code.  Workaround, this one isn't pretty either.
Bugs (Issues with no workaround found)
  • If you have multiple AOS instances for one database, sometimes compiling the code does NOT push the change to all the AOS's (probably a caching issue)
  • The MorphX editor closes and the AOT node collapses when you Check Out that object from VSS
  • The Compile window does not clear when recompiling
  • Soft breakpoints don't always work, most often in forms, because they are client ran
  • Code Profiler affects the outcome sometimes, and misses some calls, hardly useful but good in theory
  • Dragging and dropping nodes in the AOT doesn't consistently allow you to re-order nodes, you have to use Alt+Up/Down instead (Explanation)
  • Can't drag and drop objects from a project to another project without having the source project checked out, should just copy the reference in the new without trying to pull it out of the source project
  • If I have two windows both are not maximized, I maximize one, then I close it, the second window magically assumes it should be maximized as well.  And sometimes when clicking back and forth from window to window, sometimes it automatically maximizes. Why? (Seems to happen a lot with the "Find" form)
  • Some tables, for example (TaxBook/SalesPurchCycle/PBARulePBAId2ConsId/COSPlanTable), when you change the primary key or clustered index, the change is not reflected in the database
  • When importing two objects that having elements that reference each other, there is an error saying that an object doesn't exist (forces the user to import multiple times to finally get it all)
  • If a Field Group changes in a table (changing order or adding new fields in a specific order), any groups within a form (or report I presume) will not refresh and put the fields in that correct order even after a compile
  • If you create a field on a table, name it something, and later realize that it is the wrong type and delete and readd that field, same name but with a different type, fieldnum() will always return the original fieldId, not the new one.
Suggestions & Gripes
  • RecordSortedList should have the option to sort in descending order
  • When using multiples instances of AOS's, the RecId's issued may not always be in order of when it is inserted (The number sequencing behind RecId's has the option to batch request a set of RecId's at a time but may not use them in order).  Why not just use an auto-increment identity column and let the database handle what it does best?
  • date2str is a ridiculous function.  There should be Enums to go along with the parameters that date2str takes in.  Having to hard-code 213 for US date standards is not cool.
  • EDTs should have a property for data length, display length doesn't enforce what goes in the database
  • DAX is shipped with numerous instances where there are relations on varchar type fields, I was always taught that is a big no-no, a big performance degradation
  • DAX doesn't have a good event model
  • There's no good built-in way to listen to keystrokes, the workaround would be to monitor the task() method on forms, but the int values of the keystrokes that are hit are unknown.
  • No way to control and specify Shortcut keys (for buttons in forms)
  • Lack of a good API reference, MSDN is hardly sufficient (I want to know the order in which the kernel calls certain methods in Forms/Data Sources/RunBaseBatch/Reports/etc.)
  • Date and time are stored separately, why not a DateTime type, databases have been able to handle this for years
  • DataAreaId is always the first field in every index created, it makes the histograms of the statistics of the database not very useful when most companies have only one Company/DataArea
  • Projects really only consist of pointers to the real objects in the AOT, not cloned copies of the object
  • Can't check in/out a project from the Project window when you have it open
  • When compiling code, if you are calling into a method that accepts a string EDT as a parameter, it should at least show a warning when the size of that parameter being passed in could be larger than what the method is expecting to accept, otherwise truncation is possible
  • Why do we have to define all variables first and why the extra semi-colon?
  • Inability to overload methods
  • VSS is the only option for source control, in 4.0 (allows for no branching or merging/does not track objects that were deleted or renamed/no option for TFS/checkout time seems to grow significantly with the number of versions)
  • The database is not relational, each table is it's own separate entity
  • SysLastValue and it's caching mechanism, why does this need to be so complicated?
  • The layer architecture is a good idea, but when MS releases patches, we can't jam code into objects that exist in higher layers
  • Why do edit/display methods have to call the database continuously?  Debugging these are horrible.
  • No relations on Views?
  • Users are not able to create enum values, this forces most developers to make master tables so the user can manage it.  So why have enums at this point?
  • Because of SOX and PCI requirements, I wish there was a way to have read-only access to code vs no access to code (most Production environments can't allow developers access to change code per PCI/SOX)
  • Why isn't there a way to test security as another user (alias their security settings similar to SharePoint)
  • DAX doesn't have a HAVING clause, forced to create a temp table to store the data and filter the data in a WHERE
  • DAX has no concept of NULL, makes it nearly impossible to LEFT OUTER JOIN
  • Cannot seem to get more than one LEFT OUTER JOIN to work in one QueryRun object.
  • The order of DataSources within a form impacts the underlying queries, expectations can vary
  • Must have temporary tables as the innermost table vs being a table that is joining to another table? I understand why, but why can't DAX just create real temporary tables in the database so it can join to it any way we want?
  • Number sequencing is heavy on the database, why not have a separate table that stores the TableId, FieldId, and some sort pattern to display the identity column (ex. SalesId would be SO%)
  • Number Sequences are created by writing code? What? If we're so determined to bypass a standard that SQL databases have had for decades for identity columns (autoincrement); why not make it easier by having Number Sequences as an item in the AOT?  That way, you could have a field property to specify a Number Sequence object to use, and it could increment automatically?
  • Add a countdistinct(_field_) aggregate function to perform a COUNT(distinct _field_).  count() only includes a count of records, not unique records, not very useful.
  • any2str function converts an anytype object to a string ONLY if that anytype object is of type string....what? (Explanation)
  • Unable to drag objects from one project to another (copy) without having the source project checked out.
  • If new fields are added to a Field Group in a Table, any Form that uses it does add the new fields correctly, however not in the order in which the Field Group shows it, even if you compile it.
  • There is no way to compare your checked out (while working on a change) version of the code to the latest version.  This would be very handy, especially if you have multiple developers in the same environment and you want to see what the other developers have changed. (Fixed in 2012)

Wednesday, October 19, 2011

Tool to Analyze Queries from X++ Code

Sometimes when you're working in DAX you may not understand why data isn't displaying correctly or something isn't joining right. This then begs the question what SQL is being generated when you perform a task. DAX comes with a couple of tools to trace what is happening but let's be serious, those tools are far from perfect.

One tool is the SQL Trace option in the Options menu. This is a good and easy way to quickly trace simple SQL that executes, but it misses some important queries that run from deep in the kernel.

The other tool is the TraceParser. This tool requires a ton of initial setup and requires an Admin to run the tool. This is a big problem (aka. A big no-no) for anyone who works in an environment stacked with PCI and SOX compliance guidelines to follow, especially when trying to trace an issue in your Production environment. Plus when you do get it working and get proper sign-off from the executives of your business, there is a lot of work in analyzing the results, having to drill down into nested tree structures on EVERY line just to get to the query that ran. But it does do a good job matching up what query got ran from what line. In my opinion, it's a lot more work than necessary.

The caveat with both of these tools, it sometimes misses some queries that are executed, especially those that involve schema changes or other ALTER statements. Luckily, I've found an easy way to use a tool we are all familiar with, SQL Profiler. If you're not familiar, you should become well acquainted. As we know, SQL Profiler will monitor and report just about every event you can throw at a SQL server. Now, if you simply run a trace while running something in DAX and look at the resulting queries, you'll see the structure of the query, but there will be parameters (ie. @P1, @P2, etc.) in place of the real values that will be used in the query. This makes it very difficult to determine what the query actually returned (result set).

What is interesting, if you look at the RPC:Starting event just before the query in question, you will see the real values of those parameters in the last part of TextData column. Even then, looking at it, it still isn't easy to determine where those values go in the next query.

What I did is analyze a good amount of these profile trace (*.trc) files and wrote a program that parses a *.trc file and converts it to a text file that replaces all parameters with the real values so it is easier to determine what your result set REALLY is. The link is below:

SQL Trace File Parser

It isn't perfect but I did my best. It then uses a web service I found to format (indent/line break) the queries and writes them out to the text file (that also isn't perfect either, you might get really long one liners, sorry).

How to Use
  1. First, we need to open SQL Profiler. Easy enough.
  2. We'll need to create a Template in the File->Templates->'New Template...' menu.

    • Give your template a name, I named mine DAX_TRACE
    • Click on the Events Selection tab
    • SQL Profiler will trace everything that is thrown at it so we need to filter it to specific only trace events fired by DAX.  Make sure that both the checkboxes ('Show all events' and 'Show all columns') are checked and click on 'Column Filters...' and filter the two columns
      • Application Name = "Microsoft Dynamics AX" (no quotes)
      • Database Name = <The Database your DAX environment uses>

      You may choose additional filters as you see fit.
    • Now we will need to select events and columns we will be tracing
    • You may select any/all events/columns you wish but you need at least the following events:
      • RPC:Starting
      • SP:StmtCompleted
      • SQL:StmtCompleted
      And the following columns:
      • TextData
      • SPID
      • ObjectName
      Note: A quick way to save time when deselecting columns is to right-click the column header and choose 'Deselect Column'.
    • 'Save' the template
  3. Now we are set up and can trace with this same template anytime we wish.
  4. Let's begin tracing by clicking on the 'New Trace' button.  It'll ask you to connect to a SQL Server. Enter the SQL Server information and make sure it successfully makes a connection.
  5. A new window opens to provide you with options as to how you wish to trace the server.  You can give the trace a name, it doesn't matter if you leave it.  You should then select the template in which we just created in the 'Use the template' drop-down list.  Nothing additional is needed, we can worry about saving the trace file after it runs, it's not necessary to tell it where to save ahead of time.
  6. When you are ready and you have a DAX client up and ready to trace, click 'Run' and it will begin tracing.
  7. Perform the tasks you want in the DAX client.
  8. When desired, you may stop the trace by hitting the 'Stop' button.
  9. Save this as a Trace file by clicking File->'Save As'->'Trace File...' and find a place to store the file.
  10. Open SQL Trace File Parser (download from above) and browse for the file we just traced.
  11. By default, the text file will save in the same directory/filename as the trace file but with a *.sql extension instead.
  12. The Output Format is defaulted to 'Force Literals' which simulates what the query would look like if you use the forceliterals keyword in your query (replaces the parameters with real values).  'Raw Query' will just give you the original parameterized query.
  13. The Options show Pretty Print, which uses a 3rd party web service to format the SQL with proper indentation for easy readability.  If this service is unavailable and it fails, please uncheck it.
  14. Click Go and watch it churn away.
  15. Open the *.sql file and look at the beautiful SQL it found.
  16. As usual, if you spot any bugs please send message me and provide the *.trc file if possible.
I'm always open to comments and suggestions to improve this.  Let me know.

Change Log:
2014-12-10 - Feature - Changed the default output filename to a *.sql instead of *.txt
2014-12-10 - Feature - Added the option to use or not use a 3rd party web service to format the SQL