Use Power BI Semantic Models for Your Golden Datasets to Make Your Job Easier
Newsletter
Join our blog
Join other Azure, Power Platform and SQL Server pros by subscribing to our blog.
Start with the FREE community plan and get your lifetime access to 20+ courses. Get Instant Access Now!
Need help? Talk to an expert: (904) 638-5743
Private Training
Customized training to master new skills and grow your business.
On-Demand Learning
Beginner to advanced classes taught by Microsoft MVPs and Authors.
Bootcamps
In-depth boot camps take you from a novice to mastery in less than a week.
Season Learning Pass
Get access to our very best training offerings for successful up-skilling.
Stream Pro Plus
Combine On-Demand Learning platform with face-to-face Virtual Mentoring.
Certification Training
Prepare and ace your next certification with CertXP.
Private Training
All Courses
View all of the courses available on our on-demand learning platform.
By Learning Path
Explore our courses based on role-specific learning path.
By Product
Find all of the courses for the product you want to master.
Power BI
Turn data into actionable insights with our Power BI courses
Power Apps
Learn to build custom business solutions with ease
Cheat Sheets
Quick references for when you need a little guidance.
Nerd Guides
Summaries developed in conjunction with our Learn with the Nerds sessions.
Downloads
Digital goodies - code samples, student files, and other must have files.
Blog
Stay up-to-date on all things Power BI, Power Apps, Microsoft 365 and Azure.
Community Discord Server
Start here for technology questions to get answers from the community.
Career Guides
Breaking into the field? Let these guides help get you started with a plan.
Affiliate Program
Earn money by driving sales through the Pragmatic Works' Training Affiliate Program.
Reseller Partner
It's time to address your client's training needs.
Foundation
Learn how to get into IT with free training and mentorship.
Management Team
Discover the faces behind our success: Meet our dedicated team
Contact Us
How can we help? Connect with Our Team Today!
FAQs
Find all the information you’re looking for. We’re happy to help.
The IF function in DAX is a very popular logical function. It will perform a logical check on a value expression and produce a value of True or False. Based on the resulting True or False you can then decide what value you want to be reported. Your value can be a hardcoded string value or some other calculation. When you only have two outcomes to choose from the IF statement is very straightforward. But what if you have 3 or more outcomes. Then you will need to use more than one IF statement. Instead of reporting a value or calculation for your first false result, you will code in another IF statement to run. The more outcomes you need the more IF statements you will use. This can be tiring to code and hard to read. Here is where the SWITCH function comes into play.
The SWITCH function allows for an easier-to-read function compared to nested IF statements. The SWITCH function can always be used in place of the IF function. The basic workings of the SWITCH function are you decide what expression you want to be checked. Then you decide what value to look for and what result you want to be returned. If you have multiple values to check for and multiple results you can just string them along by using commas.
The SWITCH function has to be tweaked to check for inequalities because the SWITCH function is set to only search for a unique match and NOT a range of values. To work around this issue we will incorporate the TRUE() function. Take a look at this video to see how to take your complex IF statements and translate them into easier SWITCH statements.
If you enjoy this video or any of my other videos and are interested in formal training on Power BI, Power Apps, Azure, or other Microsoft products you can use my code "Matt20" to get 20% off at check out when purchasing any private training or On-Demand Learning classes from https://pragmaticworks.com/pricing/
ABOUT THE AUTHOR
Matt Peterson is a Trainer for Pragmatic Works specializing in the Power Platform. He graduated from the University of North Florida in 2006 and comes with 15 years of teaching experience in high school algebra. Matt earned the accomplishment in 2013 of being named the Florida Gifted Teacher of The Year. His primary focus is helping our customers learn the ins and outs of Power Apps and Power BI.
Free Trial
private training
Newsletter
Join other Azure, Power Platform and SQL Server pros by subscribing to our blog.
Leave a comment