8. Adding Columns: Power Query Add Column Tab and DAX Calculated Columns
8.5 Conditional Column
If–then–else rules without code. Covered with a data-quality example in Module 7.16. Here is a business example, Basket Size:
Steps in Power BI
- Add Column › Conditional Column › New column name:
Basket Size. - If Amount is less than
199→Small. - Add Clause: Else If Amount is less than
499→Medium. - Else →
Large› OK. - The Operator list changes by type (text: begins with, contains, equals; numbers: is greater than …). The Value/Output boxes can also refer to a column or a parameter (click the ABC123 drop-down).
Aata pudhe jaauya Index Column kade.
Ravindra Bagale's Tip
Friends, remember: rules are checked top to bottom, and the first match wins. Writing "< 499 → Medium" before "< 199 → Small" makes every small basket Medium. Order the rules from the smallest threshold upward and test boundary values like 199 and 200. Remember this rule.
Ravindra Bagale's Tip – मराठी
मित्रांनो, लक्षात ठेवा: rules वरून खाली तपासले जातात, आणि पहिला match जिंकतो. "< 199 → Small" च्या आधी "< 499 → Medium" लिहिलं तर प्रत्येक छोटी basket Medium होते. Rules सगळ्यात लहान threshold पासून वर जाणाऱ्या क्रमाने लावा आणि 199 आणि 200 सारख्या boundary values test करा. हा नियम लक्षात ठेवा.
Ravindra Bagale's Tip – हिंदी
दोस्तों, याद रखो: rules ऊपर से नीचे check होते हैं, और पहला match जीतता है. "< 199 → Small" से पहले "< 499 → Medium" लिखा तो हर छोटी basket Medium बन जाती है. Rules को सबसे छोटे threshold से ऊपर की ओर क्रम में रखो और 199 और 200 जैसी boundary values test करो. यह नियम याद रखो.