From the course: Learning Data Analytics: 1 Foundations

Creating logical functions

From the course: Learning Data Analytics: 1 Foundations

Creating logical functions

- [Instructor] If I've created one If Function I've created a thousand in my career. Being able to add variables to our data based on conditions is a must have skill for a data analyst. Trust me, you will need it. In Excel, we call these If functions or logical functions. In Power Query, they're called conditional columns. The organization decided they want to send a thank you note to anyone who made a sales order over $3000. We need to send this list or our marketing group so they know who to notify. So let's go look at how to create a conditional column. I'll right-click my sales order header and go to edit. I'll go ahead and expand my queries. And for now I want to actually make a copy of my sales order header. I'll right-click it. I want to use reference on this duplicate. That way, if I make changes to the main sales order header in the data, it will carry over to my marketing data. So I'll choose reference. I'll go ahead and name this one "Marketing." Let me show you how the reference works. If I go to SalesOrderHeader and I go ahead and make my display name proper case or capitalize each word, then I'll immediately see that change in my marketing. That's one of the benefits of the reference. I don't have to duplicate those cleaning steps. Okay. Now for the conditional column. I'll go to add column. I'll choose conditional column. This will be called, "Thank You Note." If the total order is greater than or equal to 3000, then I wanted it to mark it with "Thank You Note." Otherwise, I want it to just say, "No Note." I'll go ahead and click okay. And if I go to the end of my data, I can see I have thank you notes and no notes. Okay. I'll go ahead and choose close and load. Just scroll over here and make sure. Perfect. No note, and thank you. I'll go ahead and name this sheet tab, "Thank You Notes." If you've ever built an If function, you can see how this is a simple way to create conditional variables in your data.

Contents