Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

Today, I’ll show how you can control totals and subtotals in your matrix visual in LuckyTemplates. You can watch the full video of this tutorial at the bottom of this blog.

This is a problem posted by one of our members at the LuckyTemplates forum. The user wanted the columns to look like the excel pivot table tabular format with the grand total at the bottom, but not the subtotal. I’m going to share a couple of ways how you can solve this. One is through a matrix visual and the other is through DAX.

Table of Contents

Creating A Matrix Visual In LuckyTemplates

What I did was I started off with the Practice Dataset External Tool, which is a tool that we developed for exactly this purpose to create practice datasets. It creates a three-year data set with a full data model up to today’s date. It’s a basic star schema data model, but it can be used to develop a lot of good testing models.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

I just put together a matrix visual, which is very similar to what the member wanted in the forum question.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

I’ve used a very simple Total Sales measure to SUM of Line Sales within the Sales table. I’ve kept that to two products, three different channels, and then set that to four quarters within the year 2020.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

As you can see, I made four different copies of this table. Then, using the technique that I’m going to show you, you can keep the row totals and eliminate everything else, keep the column totals and eliminate everything else, keep the subtotals and vary that by individual subtotal, or take out all the subtotals and all the grand totals and just be left with the base rows. So, you’ve got full flexibility and control here, and I’ll show you how this is done.

Now, if we go to the main table, click on it, and then we go to the format, there’s an option that is per row level. Turn that on. There’s also one per column level and we make sure that’s turned on as well. We can also turn on Product Name, which turns on the grand totals at the bottom. The Channel Name turns off the subtotals, and the Quarter and Year turn off the row totals.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

You just turn those on and toggle the options. That’s the really simple and easy way to do it. The more difficult way is through DAX.

DAX Solution To Control Totals & Subtotals In A Matrix Visual In Power

You may be wondering, if we’ve got this really simple way to do this, why should we even bother with a more difficult way? It all boils down to the issue that comes up a lot in terms of incorrect totals.

And so, in this case, I’ve stripped down the example from the previous page to just quarter one and quarter two, but otherwise, it’s the same matrix visual.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

We’ve got the simple Total Sales measure and that works fine, the totals are correct. But then, if we use a more complex sales measure here, Total Sales SWITCH, this is dependent on the value of our sales channel.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

I just made up some numbers to make a point here that if we have a more complex Total Sales calculation, the numbers are incorrect (below table on the right side). If we look closely, the prior numbers, which are correct, are the same, and yet it can’t be true. When we look at export, for example, it’s 30% higher than in the previous case and yet the totals here are showing up the same. That just can’t be correct.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

So, how do you correct that?

To do this within DAX, you can use a whole series of functions, which I’ve laid out here. We have HASONEFILTER, HASONEVALUE, ISFILTERED, ISCROSSFILTERED, and ISINSCOPE. These are all used to determine among other things, whether you’re in a data row a subtotal row, or a total row.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

As you can see, they all look the same with the exception of HASONEVALUE, where it’s showing the product one subtotal. That’s just because of an artifact in the data that I’ve developed for this one, where product one only has a distributor channel. It doesn’t have an export or wholesale channel in the Sales table.

They’re not showing the grand total and the subtotals, but if we impose a slicer on this, for example, let’s pick Distributor and Wholesale, suddenly these tables change a lot.

Matrix Visual In LuckyTemplates: Controling Totals & Subtotals

And now, there’s a big difference between these tables. HASONEFILTER here doesn’t show the product one subtotal while HASONEVALUE does. ISFILTERED now shows the grand total, the row totals, and the subtotals as does ISCROSSFILTERED. ISINSCOPE, on the other hand, provides a result that’s very similar to HASONEFILTER. You can see that the imposition of that additional slicer changes the nature of what you get here.

There’s not a hard and fast answer to what you should use to fix a given total. It’s going to depend on your data model. It’s going to depend on your DAX. But the important thing here is to see that the different functions produce different results in terms of blanking out the totals versus the subtotals, and the grand total.


Using Advanced Logic In LuckyTemplates To Correct Your Totals
How To Create Unique Subtotals In LuckyTemplates Tables
How To Fix Matrix Totals In LuckyTemplates

Conclusion

The specifics of that are beyond the scope of this tutorial. Check out other tutorials on the links below for more related content. Just note that there are also oftentimes performance distinctions that you’ll find between these different functions and that will also speak to which one you choose in your ultimate measure.

I’ve shown you two techniques that you can implement to control totals and subtotals in your matrix visual in LuckyTemplates. Hopefully that gives you some good, useful tools for your toolbox.

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.