Advanced DAX Functions: Calculating Profit Contribution

In this blog, I’ll be discussing some more advanced DAX functions to demonstrate what’s possible in LuckyTemplates. You may watch the full video of this tutorial at the bottom of this blog.

This tutorial will teach you how to visualize the profit contribution of different client tiers using advanced DAX functions.

Table of Contents

Calculating Total Profits

I’m going to start by creating a new measure and renaming it as Total Costs.

Advanced DAX Functions: Calculating Profit Contribution

To get the cost, you need to use the function, which returns the sum of an expression evaluated for each row in a table.

Add the Sales table and multiply each sales quantity to the corresponding product cost.

Advanced DAX Functions: Calculating Profit Contribution

You will need to use the function to call on another table, particularly the Products Cost table, to achieve this.

Advanced DAX Functions: Calculating Profit Contribution

Hit enter and wait for the calculation to appear on your Key Measures.

Advanced DAX Functions: Calculating Profit Contribution

From here, you can branch out easily to Total Profits. Create a new measure and subtract Total Costs from Total Sales.

Advanced DAX Functions: Calculating Profit Contribution

As you may have noticed, you don’t have to reference anything in the table anymore.

This is the beauty of measure branching: you can reference measures within measures rather than having to rewrite advanced formulas repeatedly.

This methodology is a far more effective way to do complex calculations and it will save you a lot of time.

Now I’m going to drag the measures for Total Costs and Total Profits into my table.

Advanced DAX Functions: Calculating Profit Contribution

I also like to fix the format right away just so my data is organized.

Select ‘Currency’ in the format drop down menu or click the currency symbol.

Advanced DAX Functions: Calculating Profit Contribution

You now have Total Sales, Total Costs, and Total Profits. The next step is to identify who in this time selection are the top clients, the mid-ranged customers, and the rest.

Advanced DAX Functions: Calculating Profit Contribution

Creating A Supporting Table

After setting up my basic measures, I’m going to create a supporting table.

This will enable me to create dynamic groupings based on custom logic.

Click ‘Enter data’ to add a new table.

Advanced DAX Functions: Calculating Profit Contribution

Name the supporting table “Customer Groups” and add columns ‘Group’, ‘Min’, and ‘Max’.

Afterward, group the clients if they belong to the Top 50, Rank 50-200, and The Rest. Indicate the minimum and maximum ranks of each group as shown below.

Advanced DAX Functions: Calculating Profit Contribution

Whenever you create a new table in LuckyTemplates, it’s best to check and organize your data model so you have an overview of how everything is connected.

In this example, I deleted irrelevant measures and dragged my supporting table to the bottom.

As you can see, it has no relationship with my core data model. The goal is to run logic through this table based on the ranking of my customers. This step will require advanced DAX functions in LuckyTemplates.

Advanced DAX Functions: Calculating Profit Contribution

Using Advanced DAX Functions

To start, I’m going to sort my supporting table.

Go to the column tools of the Customer Groups table and sort the Groups column according to the minimum ranking. I like to do this because the data will make more sense later on.

Advanced DAX Functions: Calculating Profit Contribution

Before proceeding, I’m going to make some visualizations. I went ahead and transformed my Total Sales into a card.

Advanced DAX Functions: Calculating Profit Contribution

Then I did the same for Total Profits.

Advanced DAX Functions: Calculating Profit Contribution

With all that set up, I’m going to bring in my Total Profits measure inside the Customer Groups table.

Since there is no relationship between the two, you’ll see that the Total Profits of $5.01 million goes across every single customer group.

Advanced DAX Functions: Calculating Profit Contribution

To fix this, I’m going to create a new measure and write an advanced formula. While it is complicated, using advanced DAX functions in LuckyTemplates will make this achievable.

I’m going to show you the entire formula for Customer Group Profits first and then I’ll explain what each line does.

Advanced DAX Functions: Calculating Profit Contribution

Running the advanced DAX function and inserting the measure into your table will give you the Total Profits of each customer group.

Advanced DAX Functions: Calculating Profit Contribution

So how did this happen?

The formula generated context to relate the supporting table to Total Profits.

The function was used to call on Total Profits but in the context of a modified filter.

Advanced DAX Functions: Calculating Profit Contribution

Using , the advanced DAX function iterated profits per customer by calling on each Customer Name.

Moreover, enables it to add a table function. In this case, it’s bringing up my list of customers.

Advanced DAX Functions: Calculating Profit Contribution

Data was filtered further using . This function worked out the ranking of every customer based on Total Profits.

It also determined if a customer’s ranking is greater than the minimum ranking of each customer group or less than or equal to the maximum ranks. This way, each entry fell only within one group without any overlap.

In short, RANKX was responsible for sorting customers into their appropriate Customer Groups.

Advanced DAX Functions: Calculating Profit Contribution

Meanwhile, specified that if there is one more row remaining in the table, the customer should be included in that particular group.

Advanced DAX Functions: Calculating Profit Contribution

In the end, you’re able to go through every customer and evaluate if they fall within the minimum and maximum ranks of a particular row. This will place them either in the Top 50, Rank 50-200, or The Rest.

These advanced DAX functions make it possible for the Customer Group Profits column to show the total profits of a specific customer group.

Advanced DAX Functions: Calculating Profit Contribution

Calculating the Percentage Contribution Of Each Bracket

The analysis can be taken further by calculating the percentage of profits per customer group.

For this, you’ll need too create a new measure called Customer Profit Group Percent.

Use to get the percentage of the Customer Group Profits by the Total Profits. The Total Profits always evaluates to $5M in this context.

Advanced DAX Functions: Calculating Profit Contribution

Drag the measure into your table and fix the format.

Advanced DAX Functions: Calculating Profit Contribution

Now you have a column for the Customer Profit Group Percent. As you can see, its values are what you get when you divide the profit of a specific customer group by the Total Profits.

Advanced DAX Functions: Calculating Profit Contribution

You can actually remove intermediary columns like Total Profits and the advanced DAX function will run the calculation just fine behind the scenes.

Advanced DAX Functions: Calculating Profit Contribution

What’s great about this is you can add additional context then make visualizations of the result. Just copy the table and then drag fields into Values.

Here, I added Month & Year and turned it into a percentage chart.

Advanced DAX Functions: Calculating Profit Contribution

I swapped around which fields go into the axis and legend. Month & Year needs to be on the Axis while Groups should be placed on Legend.

Advanced DAX Functions: Calculating Profit Contribution

What I have now is a bar graph that shows which customer group gives the most profit per month and how the trend changes over time.

Advanced DAX Functions: Calculating Profit Contribution


Manage Multiple Date Calculations In Your Fact Table – Advanced LuckyTemplates Technique
Optimizing Your LuckyTemplates Formula Using Advanced DAX Functions
Data Segmentation Techniques Based On Any Measure – Advanced DAX

Conclusion

Advanced DAX functions are valuable tools in LuckyTemplates. They are versatile and can give you rich insights for your reports. Hopefully this tutorial has given you an idea of how to use them in your own context.

In the next blog posts, I’ll discuss what else you can do with advanced DAX functions. Until then, try exploring this example on your own.

All the best!

Leave a Comment

Excel Hücrelerini Metne Sığdırma: 4 Kolay Çözüm

Excel Hücrelerini Metne Sığdırma: 4 Kolay Çözüm

Excel hücrelerini metne sığdırmak için güncel bilgileri ve 4 kolay çözümü keşfedin.

Bir Excel Dosyasının Boyutu Nasıl Küçültülür – 6 Etkili Yöntem

Bir Excel Dosyasının Boyutu Nasıl Küçültülür – 6 Etkili Yöntem

Bir Excel Dosyasının Boyutunu Küçültmek için 6 Etkili Yöntem. Hızlı ve kolay yöntemler ile verilerinizi kaybetmeden yer açın.

Pythonda Self Nedir: Gerçek Dünyadan Örnekler

Pythonda Self Nedir: Gerçek Dünyadan Örnekler

Python'da Self Nedir: Gerçek Dünyadan Örnekler

Rde Bir RDS Dosyası Nasıl Kaydedilir ve Yüklenir

Rde Bir RDS Dosyası Nasıl Kaydedilir ve Yüklenir

R'de bir .rds dosyasındaki nesneleri nasıl kaydedeceğinizi ve yükleyeceğinizi öğreneceksiniz. Bu blog aynı zamanda R'den LuckyTemplates'a nesnelerin nasıl içe aktarılacağını da ele alacaktır.

İlk N İş Günü Tekrar Ziyaret Edildi – Bir DAX Kodlama Dili Çözümü

İlk N İş Günü Tekrar Ziyaret Edildi – Bir DAX Kodlama Dili Çözümü

Bu DAX kodlama dili eğitiminde, GENERATE işlevinin nasıl kullanılacağını ve bir ölçü başlığının dinamik olarak nasıl değiştirileceğini öğrenin.

LuckyTemplatesda Çok İş Parçacıklı Dinamik Görsel Tekniği Kullanarak Öngörüleri Sergileyin

LuckyTemplatesda Çok İş Parçacıklı Dinamik Görsel Tekniği Kullanarak Öngörüleri Sergileyin

Bu eğitici, raporlarınızdaki dinamik veri görselleştirmelerinden içgörüler oluşturmak için Çok Kanallı Dinamik Görseller tekniğinin nasıl kullanılacağını kapsayacaktır.

LuckyTemplatesda İçeriği Filtrelemeye Giriş

LuckyTemplatesda İçeriği Filtrelemeye Giriş

Bu yazıda, filtre bağlamından geçeceğim. Filtre bağlamı, herhangi bir LuckyTemplates kullanıcısının başlangıçta öğrenmesi gereken en önemli konulardan biridir.

LuckyTemplates Çevrimiçi Hizmetindeki Uygulamaları Kullanmak İçin En İyi İpuçları

LuckyTemplates Çevrimiçi Hizmetindeki Uygulamaları Kullanmak İçin En İyi İpuçları

LuckyTemplates Apps çevrimiçi hizmetinin çeşitli kaynaklardan oluşturulan farklı raporların ve içgörülerin yönetilmesine nasıl yardımcı olabileceğini göstermek istiyorum.

Fazla Mesai Kâr Marjı Değişikliklerini Analiz Edin - LuckyTemplates ve DAX ile Analitik

Fazla Mesai Kâr Marjı Değişikliklerini Analiz Edin - LuckyTemplates ve DAX ile Analitik

LuckyTemplates'da ölçü dallandırma ve DAX formüllerini birleştirme gibi teknikleri kullanarak kâr marjı değişikliklerinizi nasıl hesaplayacağınızı öğrenin.

DAX Studioda Veri Önbellekleri İçin Materyalleştirme Fikirleri

DAX Studioda Veri Önbellekleri İçin Materyalleştirme Fikirleri

Bu öğreticide, veri önbelleklerini gerçekleştirme fikirleri ve bunların DAX'ın sonuç sağlama performansını nasıl etkilediği tartışılacaktır.