Menu
CoddyTech

استخدام SWITCH(TRUE()) للنطاقات

جزء من قسم DAX باستخدام CALCULATE في رحلة Power BI على Coddy. الدرس 20 من 24.

SWITCH(TRUE(), test1, result1, test2, result2, else): يفوز أول اختبار صحيح.

Price Band = SWITCH(TRUE(), Products[UnitPrice] >= 10, "Premium", Products[UnitPrice] >= 4, "Standard", "Budget")

ضع الاختبار الأضيق أولًا، وإلا فسيطابق الاختبار الأوسع صفوفه.

challenge icon

التحدي

سهل

أضف عمود Price Band إلى Products: "Premium" لسعر وحدة يبلغ 10 أو أكثر، و"Standard" لسعر يبلغ 4 أو أكثر، و"Budget" لما تبقى.

جرّب بنفسك

Price Band =
ProductCategoryPrice Band
EspressoCoffee
LatteCoffee
CappuccinoCoffee
الحقول
  • Sales
  • Products
    • ProductID
    • Product
    • Category
    • UnitPrice
    • UnitCost
  • Stores
  • Customers
  • Dates
  • Targets

جميع دروس DAX باستخدام CALCULATE