Dax.Formatter 1.1.1

.NET 6.0 .NET Standard 2.0
dotnet add package Dax.Formatter --version 1.1.1
NuGet\Install-Package Dax.Formatter -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dax.Formatter" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dax.Formatter --version 1.1.1
#r "nuget: Dax.Formatter, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dax.Formatter as a Cake Addin
#addin nuget:?package=Dax.Formatter&version=1.1.1

// Install Dax.Formatter as a Cake Tool
#tool nuget:?package=Dax.Formatter&version=1.1.1

Dax Formatter CI

DAX Formatter is a service available at https://www.daxformatter.com. The service receives DAX expressions and format them according to rules for DAX code formatting. The NuGet package contains a client library to invoke the service from your .NET application. All the requests are designed to be asynchronous. You should minimize the requests made to the service: to format multiple expressions, use a single API call providing the DaxFormatterMultipleRequest structure.

Quick guide

Create an instance of DaxFormatterClient. Invoke the FormatAsync method for each request. Possibly, use the DaxFormatterMultipleRequest structure to provide more statistical details about the database and the server (all the names are anonymized and used only to count the number of unique servers/databases serviced).

DaxFormatterClient

The default constructor creates an instance of the client using the current assembly name and version to identify the client. You can specify an application name and version in the constructor arguments. The client instance resolve the server endpoint just once and reuse it in following requests. It is suggested to reuse the same instance in multiple requests to minimize the latency.

var formatter = new DaxFormatterClient();
var response = await formatter.FormatAsync( "evaluate('Table') order by 'Table'[Column]" );

DaxFormatterMultipleRequest

Use the DaxFormatterMultipleRequest class to send multiple DAX expressions in a single API call.

var formatter = new DaxFormatterClient();
var request = new DaxFormatterMultipleRequest
{
    DatabaseName = "MyDatabaseName", // The name will be anonymized by the client library
    ServerName = "MyServerName",     // The name will be anonymized by the client library

    // Format arguments (you can skip all of them to keep the default values)
    ListSeparator = ',',
    DecimalSeparator = '.',
    MaxLineLength = DaxFormatterLineStyle.LongLine,
    SkipSpaceAfterFunctionName = DaxFormatterSpacingStyle.BestPractice,

    // Identify the server type using the corresponding enum values
    ServerMode = Dax.Formatter.AnalysisServices.ServerMode.Tabular,
    ServerType = Dax.Formatter.AnalysisServices.ServerType.AnalysisServices,
    ServerEdition = Dax.Formatter.AnalysisServices.ServerEdition.Enterprise,
    ServerLocation = Dax.Formatter.AnalysisServices.ServerLocation.OnPremise,
};

// Add the code to format    
request.Dax.Add( "evaluate('Table') order by 'Table'[Column]" );
request.Dax.Add( "[X]:=CALCULATE([Amt],USERELATIONSHIP(Sales[DueDateKey],'Date'[DateKey]))" );

// Send the request and wait the result
var responses = await formatter.FormatAsync(request);

// Process the result
foreach (var response in responses)
{
    Console.WriteLine(response.Formatted);
}

DaxFormatterSingleRequest

Use the DaxFormatterSingleRequest class to send one DAX expressions in a single API call.

var formatter = new DaxFormatterClient();
var request = new DaxFormatterSingleRequest
{
    Dax = "evaluate('Table') order by 'Table'[Column]",

    DatabaseName = "MyDatabaseName", // The name will be anonymized by the client library
    ServerName = "MyServerName",     // The name will be anonymized by the client library

    // Format arguments (you can skip all of them to keep the default values)
    ListSeparator = ',',
    DecimalSeparator = '.',
    MaxLineLength = DaxFormatterLineStyle.LongLine,
    SkipSpaceAfterFunctionName = DaxFormatterSpacingStyle.BestPractice,

    // Identify the server type using the corresponding enum values
    ServerMode = Dax.Formatter.AnalysisServices.ServerMode.Tabular,
    ServerType = Dax.Formatter.AnalysisServices.ServerType.AnalysisServices,
    ServerEdition = Dax.Formatter.AnalysisServices.ServerEdition.Enterprise,
    ServerLocation = Dax.Formatter.AnalysisServices.ServerLocation.OnPremise,
};
 
// Send the request and wait the result
var response = await formatter.FormatAsync(request);

// Display the result
Console.WriteLine(response.Formatted);
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 2,450 5/11/2022
1.1.0 645 4/26/2022
1.1.0-preview1 136 4/24/2022
1.0.0 1,894 3/6/2021