# Power BI Advanced Analytics: Secondary Table Logic Techniques

In this tutorial, I’m going to run through some advanced analytics techniques within Power BI and the DAX formula language that I call secondary table logic. You may watch the full video of this tutorial at the bottom of this blog.

Sometimes when using Power BI for your analytics, you’ll want to find or discover interesting insights, but the current data you’re working with may not allow you to extract such insights.

Which is why sometimes it’s crucial to create secondary tables to bring in such information to your core data model.

I show from start to finish how you need to think analytically about utilizing these tables, but then also how to implement them in a really practical way.

We learn better by doing, and so I’ll take you through a practical example of how you can go about doing this on your own. I’ll demonstrate how you can bring in various information or insights to your data analysis that really showcase things in a much more effective way.

So here we work out the total sales of our salespeople in the last 60 days. And then based on that, we will dynamically classify them as good, mid-range, or bottom salespeople.

As we go through time, we can look back in the last 60 days and see which salespeople at any 60-day period are selling really well.

## Branching Out For Secondary Table Logic

Before we dive into creating the secondary table logic, let’s go through the calculations involved in achieving this.

This example here is static in terms of the built-in demo data set, so I had to create a formula that retrieves the last date of my sales table.

I specifically intend it that way for this demonstration, but you can have it in another way in your own data sets that it would be updating every day. Here’s the formula I created to get the Last Date.

From this, we can then feed this formula into our calculation, Transactions Last 60 Days. In this calculation, we go CALCULATE COUNTROWS of the Sales table. Then, we open the dynamic 60-day window by using FILTER ALL Dates that iterates through the Dates table, which then gives us the results we are looking for.

This is going to show us the total sales that any sales person has made in the last 60 days on a rolling basis, as we move through time. As we filter this, we can see our worst and best salespeople.

We can also make this look more visually appealing by using some Data Bars. We go Conditional formatting,

then change it up a little bit with some colors.

Now we can see clearly our top sales people based on the last 60 days in this data set.

Now this is where the secondary table logic comes in. We’ll group these salespeople based on how many products they sell.

This insight will help us manage our people well, and make better decisions in terms of giving rewards or perhaps even firing those who are not performing at all.

## Creating The Secondary Table

A secondary table logic is necessary here because this is a dynamic calculation. We can’t put this into the lookup table. We need to be able to iterate through the numbers into the logic in a secondary table to then group these people.

So to create another table, we go Enter Data, then type in the title and the columns.

We create our Min and our Max, and then put in the values that we intend to have. Then, we click on Load.

Once that’s loaded up, we’ll have it inside our model. Note that a secondary table has no relationship with our data model. It only sits out here and we don’t connect it to anything because we don’t need to.

This is the table we need to iterate through. This means that for each sales person and the result we got from our Transaction Last 60 Days, we’ll determine which group they belong based on our Min and Max here.

So now we need to write a formula that would enable us to work out what that is.

## Using Secondary Table Logic To Extract Insights

To extract these insights, we need to create a new measure first. We’re going to be returning a text value here because we’ll be putting these people into a group.

Let’s call this formula Salespeople Performance Group. We utilize the function CALCULATE to SELECTEDVALUE, which is our secondary table logic, where it will find and return one text value (top, OK, poor). We put an alternative result (BLANK) just in case.

Then, on the next line is where we put our secondary table logic. And we use the FILTER function, as it iterates through ALL our Salespeople Logic.

With this logic, we will find out the group that a particular sales person is in, and that group will be dynamic because this measure is dynamic. And so if we bring this into our table, then we’ll now see the results.

We grabbed a particular figure from another table, which I call a secondary table, and then brought it in via measures into our model.

## Conclusion

This is the power of advanced analytics in Power BI. By utilizing secondary table logic, we don’t need those intermediary calculations. The formula is doing all the hard work for us.

These are all the tips you need to be able to grasp this unique concept in Power BI. These techniques are actually quite unique to Enterprise DNA and to some of the best practice development that weâ€™re completing.

It is only after you read this blog and watch the video below that you’ll get to understand exactly what I mean. So go ahead and review the video. I can promise there is a lot to learn.

Your mind will expand exponentially in terms of the analysis and information that you can get into your reports.

Good luck!

Sam

Sam McKay, CFA
Sam is Enterprise DNA's CEO & Founder. He helps individuals and organizations develop data driven cultures and create enterprise value by delivering business intelligence training and education.

## Tooltips In Power BI | New Modern Visual Tooltips Review

Today, I want to talk about the new tooltips in Power BI â€“ the new Modern Visual tooltips. I think has...

## Power Query Functions, Keywords, And Identifiers

This tutorial will discuss Power Query functions, keywords, and pre-defined identifiers. You'll learn...

## Find Out How To Quickly Create Virtual Groups In Power BI

Did you know there is a way to create groups virtually in Power BI? You may watch the full video of...

## DateTime Value: How To Strip Off Seconds

In todayâ€™s blog, we will examine three ways to strip off seconds from a DateTime value. You can...

## Course Completion Certificates Now Available At Enterprise DNA Online

TheÂ Enterprise DNA Team has been working hard to deliver a brand-new certificate offering for those...

## Selenium IDE In Power Automate UI Flows

In this tutorial, we'll discuss the Selenium IDE option in Power Automate UI flows. When creating UI...

## Using The DAX Studio User Interface: An Overview

In this tutorial, weâ€™ll go through a quick overview of all the options available in the user interface...

## See Changing Results Using Calculated Columns In Power BI

In this tutorial, I'm going to run through a number of great analytical techniques that you can combine...

## InfoPath: Explained With Examples

Are you tired of drowning in a sea of paperwork and struggling to keep your data organized? Enter...

## Retail Management & Demand Forecasting Reports In Power BI

In this Power BI Showcase, we focus on reports that provide analysis on retail management,...

## First N Business Days Revisited – A DAX Coding Language Solution

Let's take another look at the problem discussed in this tutorial, which dynamically compared the first...

## Showcasing Multiple Selections In A Power BI Slicer

Many of you may know that we regularly conduct Power BI Challenges. There are lots of techniques that I...