Future-Proof Your Career, Master Data Skills + AI

Blog

Blog

# How To Use SWITCH True Logic In Power BI

by | 9:00 am EDT | March 29, 2020 | DAX, Power BI

When utilizing SWITCH / True Logic inside Power BI, you really do open up this huge expanse of analytical opportunities. You may watch the full video of this tutorial at the bottom of this blog.

In this tutorial, I’ll run through how you need to set up your formulas when using the SWITCH function. This will enable you to find, discover, and visualize many different and interesting insights within Power BI.

There are so many different ways that you can utilize SWITCH in Power BI. It’s like a Nested IF statement that you would use in Excel but it’s much more powerful and cleaner.

This is why it’s essential to try and incorporate this into your models if there is an appropriate place to do so.

I’ll show you different ways that you can utilize the SWITCH statement. Once this settles in, you’ll immediately see many other places in your own reports and environments, where you can utilize the SWITCH statement.

## Dynamic Report Created With SWITCH TRUE Logic

What we’re looking at here was part of the Enterprise DNA Webinar Series that I ran through around visualization techniques. If you want to see how I built this from scratch, utilizing a number of different techniques, check out the full workshop.

SWITCH True logic is one of the crucial techniques I used to create this dynamic report. In fact, it’s really the only way that you could create some of the elements and features of this particular report.

This entire report is entirely dynamic.  You can select a particular metric then it returns results based on that selection. You can choose to highlight Revenue, Costs, or Profits.

## How SWITCH TRUE Logic Works

The great thing about SWITCH True logic or statement is it’s just like Nested IF statement, which enables you to run through row by row in the formula.

You run through some calculations and evaluate them as true. If they’re true, they will return a result.

But this logic can return basically anything, not just a result. It enables you to return a measure, a value, or a text. You can also feed in a table function. There’s so much you can do with this logic. It’s a bit more advanced, but it enables you to combine lots of different formulas and quite complex Nested IF statements in a really effective way.

So in this case, what I used was SWITCH True to evaluate the rows. For example, if the metric selected over the slicer selection is Revenue then return this entire Total Sales measure.

So regardless of what sits in behind this Total Sales measure, it will calculate and return that particular result based on the context of Total Sales. The same goes with the next rows; Total Costs for Costs metric, and Total Profits for Profits metric.

If none of these metrics return something, then it’ll return Total Sales as the alternative result.

You could make that blank or anything you want to have as the alternative result if nothing equals to true in the different logic you put inside SWITCH.

## Conclusion

SWITCH function in Power BI is a really versatile and flexible function that has many great applications within any report that you might be developing. You can utilize it in different situations and with different formulas, such as CALCULATE statement and iterating functions.

I wish you all the best in learning and implementing this in your own reports and dashboards.

Good luck diving into this video tutorial!

Sam

## How to Calculate Age in Excel: 5 Best Methods Explained

Looking to calculate age in Excel? Well, you're in the right place. Whether you need to find the age of...

## Funny ChatGPT Prompts: 20 Hilarious ChatGPT Ideas

In a world where technology continues to amaze us, we have now arrived at the point where we can have a...

## How Many Rows Can Tableau Handle?

Are you dealing with a large data set? Are you wondering how many rows can Tableau handle efficiently?...

## How to Update Tableau in 4 Quick Steps

With frequent updates and new releases, Tableau continues to evolve and improve its functionality. To...

## Power BI Slicer Search: User Guide With Examples

Ready to get started with the Power BI slicer? This feature will allow you to filter and slice your...

## What is Context Filter in Tableau? How to Apply and Set

One of the powerful features of Tableau is its ability to allow users to interact with data...

## How to Number Columns in Excel Automatically: 5 Quick Ways

In Excel, numbering columns is an important and straightforward process that can help you organize and...

## How to Make a Logo Transparent in PowerPoint: Quick Guide

A transparent logo can be a powerful tool in your branding arsenal. It allows your logo to seamlessly...

## Excel Waterfall Chart: Guide to Create, Design & Impress

Have you heard of an Excel waterfall chart but are unsure how to create one and make it stand out?...

## Tableau Tooltip: A Design Guide for Customization

Are you ready to use Tableau tooltips to level up your visualizations and make them more insightful and...

## What is a Set in Tableau and How to Create Them: User Guide

Are you getting started with Tableau and looking to create a set? Well, you're in the right place. In...

## How to Alternate Colors in Excel: 3 Top Ways Revealed

Knowing how to alternate colors in Excel can be a game-changer; there's little more satisfying than a...