# 13.9 FILTER

Source: https://ravindrabagale.com/mr/powerbi/ch13-dax-data-analysis-expressions/13-9-filter.html
Language: mr (Marathi with English technical terms)

FILTER(table, condition) condition true असलेल्या rows ची table देतो. तो iterator आहे. Measure-based किंवा अनेक columns च्या complex logic साठी उपयोगी.

Loyal Customers =
COUNTROWS(
    FILTER(VALUES(Customer[Customer ID]), [Total Orders] >= 10)
)

Sales from Loyal Customers =
CALCULATE(
    [Total Sales],
    FILTER(VALUES(Customer[Customer ID]), [Total Orders] >= 10)
)

Slow Stores =
COUNTROWS(
    FILTER(VALUES(DarkStore[Store ID]), [Avg Delivery Time (mins)] > 15)
)

Loyal Customers example मध्ये सध्याच्या filter period मधल्या ≥10 orders असलेले customers घेतले आहेत; तो आपोआप lifetime loyalty नाही. Slow Stores मध्ये current average >15 हा practice threshold आहे.

शक्य असेल तर छोटा column filter

CALCULATE([Total Sales], Orders[Discount] > 0) पुरेसं असताना पूर्ण Orders table FILTER करू नका. छोट्या column list वर filtering अधिक स्पष्ट आणि अनेकदा कार्यक्षम ठरते.

रवींद्र बागले यांची tip

FILTER result table असतो; card ला थेट scalar म्हणून देता येत नाही. COUNTROWS, CALCULATE किंवा iterator मध्ये वापरा. Customer measure condition साठी FILTER(VALUES(Customer[Customer ID]), …) वापरता येतं.
