Ravindra Bagale · Power BIसर्व coursesया course चे lessonsशोधाEnglish

Power BI · मराठी आवृत्ती

8.4 Invoke Custom Function

रवींद्र बागले यांच्या course वर आधारित · सहज मराठीत explanation

एकच logic Blinkit आणि Amazon Now queries मध्ये वापरायचं किंवा प्रत्येक page साठी request करायची असेल तर reusable function उपयोगी.

  1. Home › New Source › Blank Query › Advanced Editor मध्ये code paste करा.
  2. Query ला fnDeliveryBand नाव द्या.
  3. Orders › Add Column › Invoke Custom Function निवडा.
  4. Column Delivery Band; function fnDeliveryBand; mins साठी Delivery Time Mins column द्या.
  5. Result Text ठेवा आणि दुसऱ्या query मध्येही हाच function वापरा.
// fnDeliveryBand
(mins as nullable number) as text =>
    if mins = null then "Not delivered"
    else if mins <= 10 then "0-10 min"
    else if mins <= 15 then "11-15 min"
    else if mins <= 30 then "16-30 min"
    else "30+ min"

Band limits बदलल्यावर एकच function edit करावं लागतं. Invalid negative minutes वेगळे flag करून ठेवा.

Practice

fnPaymentGroup(mode as text) as text बनवा: UPI / Card / Wallet → Digital, बाकी Cash असा practice rule. प्रत्यक्ष data मध्ये Unknown व इतर modes साठी स्वतंत्र नियम ठरवा.