Analysis Services tabular models can have hundreds of base DAX measures, duplications of code, and syntax. However, with the new world of DAX Calculation groups we can re-use calculations and apply them to virtually any measure.
Within analysis services, DAX Calculation Groups give the user the ability to apply multi-use calculations to measures. This feature is available on Analysis Services in SQL Server 2019 2.3 and should be available in the SQL Server 2019 release. Currently, calculation groups can only be created with the Tabular Editor UI.
The first, and most prominent example of this is time intelligence and the application of MTD (Month to Date), YTD (Year to Date), and QTD (Quarter to Date) calculations. By reducing the number of measures, with calculation groups we can present a clearer user interface to the users.
Below are two images that show the calculation group hierarchy. The hierarchy is used to call a calculation on a measure.
The calculation group is called calculation group, the attribute is called time, and the item is called MTD.
The calculation items use the new ‘SelectedMeasure’ function. When called ‘SelectedMeasure’ will replace the measure that you have selected for calculation.
CALCULATE(SELECTEDMEASURE(), DATESMTD(DimDate[Date])) CALCULATE(SELECTEDMEASURE(), DATESYTD(DimDate[Date])) CALCULATE(SELECTEDMEASURE(), DATESQTD(DimDate[Date]))
The script below calculates the measure ‘InternetTotalSales’ upon the calculation items; ‘Current’, ‘QTD’, ‘YTD’ etc.
EVALUATE CALCULATETABLE ( SUMMARIZECOLUMNS ( DimDate[CalendarYear], DimDate[EnglishMonthName], "Current", CALCULATE ( [InternetTotalSales], 'CalculationGroup'[Time] = "Current" ), "QTD", CALCULATE ( [InternetTotalSales], 'CalculationGroup'[Time] = "QTD" ), "YTD", CALCULATE ( [InternetTotalSales], 'CalculationGroup'[Time] = "YTD" ), "PY", CALCULATE ( [InternetTotalSales], 'CalculationGroup'[Time] = "PY" ), "PY QTD", CALCULATE ( [InternetTotalSales], 'CalculationGroup'[Time] = "PY QTD" ), "PY YTD", CALCULATE ( [InternetTotalSales], 'CalculationGroup'[Time] = "PY YTD" ) ), DimDate[CalendarYear] IN { 2012, 2013 }
And, when we run this script we get the following table:
Looking forward, we should see this eventually in PowerBI, SQL Server Data tools, and Azure Analysis Services. So, watch this space. Read more from Microsoft here
Throughout this year, you will see more blogs and guides from me on this topic as it unfolds.
Introduction to Data Wrangler in Microsoft Fabric
What is Data Wrangler? A key selling point of Microsoft Fabric is the Data Science
Jul
Autogen Power BI Model in Tabular Editor
In the realm of business intelligence, Power BI has emerged as a powerful tool for
Jul
Microsoft Healthcare Accelerator for Fabric
Microsoft released the Healthcare Data Solutions in Microsoft Fabric in Q1 2024. It was introduced
Jul
Unlock the Power of Colour: Make Your Power BI Reports Pop
Colour is a powerful visual tool that can enhance the appeal and readability of your
Jul
Python vs. PySpark: Navigating Data Analytics in Databricks – Part 2
Part 2: Exploring Advanced Functionalities in Databricks Welcome back to our Databricks journey! In this
May
GPT-4 with Vision vs Custom Vision in Anomaly Detection
Businesses today are generating data at an unprecedented rate. Automated processing of data is essential
May
Exploring DALL·E Capabilities
What is DALL·E? DALL·E is text-to-image generation system developed by OpenAI using deep learning methodologies.
May
Using Copilot Studio to Develop a HR Policy Bot
The next addition to Microsoft’s generative AI and large language model tools is Microsoft Copilot
Apr