SWITCH It Up
PC: foolshope, pixabay (https://pixabay.com/photos/switches-old-switch-vintage-retro-2137176)

SWITCH It Up

In order to master managing data models, learning how to leverage conditional logic is a must. We see conditional logic in Excel functions like the IF function. However, those who use Excel a lot will know how cumbersome nesting conditional statements within the function become with multiple conditions. One way to streamline this process is by using the newer IFS function in Excel. Here's one way that I visualize the difference between the IF and IFS functions.

No alt text provided for this image

Another way that I visualize the logic for the {if, else if, else} conditions is a bit like combinatorics or sorting algorithms. If we focus on a single row within a data table, whatever condition that row first meets determines the result that it returns. Once we assign a row a result, it's taken out of the remaining rows for the next condition and the conditions after that we can assign it to. This means that with each additional condition, there are typically fewer rows still waiting for their result assignments. We can then set a catch-all condition with the else result.

No alt text provided for this image
How if

We can also tap into the SWITCH function in Excel and Power BI to set up multiple conditions. Let's explore two ways to use the SWITCH function in DAX measures in Power BI!

SWITCH Option 1

The first way uses exact conditions, as we can see in the example lesson below. I also use the FLOOR and CEILING functions in conjunction with the SWITCH function.

No alt text provided for this image
Power BI Weekly: SWITCH DAX function

SWITCH Option 2

We can also use SWITCH for inequalities in conditional logic. I explore how to do this in one of my latest Power BI Weekly videos!

No alt text provided for this image
Power BI Weekly: Using DAX SWITCH function with multiple conditions

Comparing SWITCH Options

So how do these functions compare? Here's a graphic comparing both of them in example DAX measure functions. It's a high-level overview of the Power BI Weekly videos above, so check those out first!

No alt text provided for this image
Comparing two version of DAX SWITCH function

Coming Up

I have two courses coming up in the pipeline for release with LinkedIn Learning. Here's a sneak peek snapshot of what I'm stitching together!

No alt text provided for this image

Also, stay tuned for the latest Power BI Weekly videos (I share them every week when they come out). If you live in Houston, check out our monthly user group meeting at the Microsoft offices in City Centre (I'll post exact details on the next meeting when we confirm them).

-HW

Ayushi Rajput

"Data Analyst skilled in Power BI, Joins, Macros, and Data Visualization, seeking new opportunities to leverage expertise in driving data-driven insights and decision-making..

1 年
回复
Kuldipsinh Chauhan

SEO Executive ?? Digital Marketer

1 年

???? Fascinating connection! Conditional logic is a powerful tool for data modeling, allowing us to manipulate data with precision. Excel and Power BI's IF and SWITCH functions enable efficient control of flow and error handling. Your newsletter promises valuable insights on leveraging these functions, making data analysis more efficient and insightful. Looking forward to exploring the intriguing link between old analog switches and modern data modeling. ????

回复

要查看或添加评论,请登录

Helen Wall的更多文章

  • Flying on Autopilot

    Flying on Autopilot

    I remember taking a plane flight several years ago with a roller coaster landing. It was an otherwise uneventful short…

    2 条评论
  • Releasing Snakes into the Wild

    Releasing Snakes into the Wild

    This week brings big news in both the Excel and Python communities! Python in Excel is now generally available as of…

    4 条评论
  • Slithering Back In

    Slithering Back In

    I'm finally catching up on the latest editions of my newsletter after a bit of a break. Writing newsletters or any kind…

    2 条评论
  • The Modern Updates

    The Modern Updates

    As I was perusing potential updates for my home recently, I started to think about how the definition of "modern" will…

  • WINDOWs of the World

    WINDOWs of the World

    It's really hard to get very far in data science without knowing SQL. Within SQL there are different levels of…

    3 条评论
  • Straightening Things Out

    Straightening Things Out

    When I took linear algebra in college, my favorite part of the class was the end of it. The course was highly…

    2 条评论
  • Seeing Dots

    Seeing Dots

    I use data visualizations not only to communicate data models to end-users who are stakeholders, but I also personally…

    5 条评论
  • The Digital Rolodex

    The Digital Rolodex

    A few months ago, I was doing my civic duty as part of a potential jury panel. While we were waiting for the court to…

    4 条评论
  • Making the "Old" New

    Making the "Old" New

    I talk with a lot of people about whether their organization uses custom visuals in Power BI. Their answers often vary…

    4 条评论
  • Patching Holes

    Patching Holes

    While I would love to live in a world where all data is perfect, I know that’s not reality. And not even close to…

    5 条评论

社区洞察

其他会员也浏览了