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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
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 3,067 5/11/2022
1.1.0 694 4/26/2022
1.1.0-preview1 147 4/24/2022
1.0.0 1,952 3/6/2021