10. Parameters in Power Query (and Other Kinds of Parameters)
10.5 Date-range Parameters for Filtering
Loading 5 years of orders on a training laptop is slow. A StartDate parameter limits the rows, and with SQL sources the filter folds into the SQL WHERE clause.
Steps in Power BI
- Create
StartDate(Type Date, current value 01-01-2025) and optionallyEndDate. - In Orders, click the Order DateTime filter arrow › Date/Time Filters › Custom Filter (or Is After or Equal To). In the value box click the drop-down › Parameter ›
StartDate. - Because Order DateTime is Date/Time and StartDate is Date, adjust the formula (below) to compare like with like.
- Right-click the step › View Native Query to confirm the
WHEREclause (Module 4.4).
Filtered = Table.SelectRows(Orders, each
[OrderDateTime] >= DateTime.From(StartDate) and
[OrderDateTime] < DateTime.From(Date.AddDays(EndDate, 1)))
Tip
A DevMode True/False parameter can switch between a small sample and the full data: if DevMode then Table.FirstN(Filtered, 5000) else Filtered. Remember to set it to false before publishing.
Ravindra Bagale's Tip
Friends, many students filter with a date parameter on a text column and get no rows or errors. Make sure the column and the parameter have the same type (Date vs Date/Time). For incremental refresh, use Date/Time and filter with >= RangeStart and < RangeEnd so no row is counted twice. Try it once more, then move on.
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students text column वर date parameter ने filter लावतात आणि त्यांना एकही row मिळत नाही किंवा errors येतात. Column आणि parameter चा type सारखा आहे याची खात्री करा (Date vs Date/Time). Incremental refresh साठी Date/Time वापरा आणि >= RangeStart आणि < RangeEnd ने filter लावा, म्हणजे कोणतीही row दोनदा मोजली जाणार नाही. पुन्हा एकदा करून बघा, मग पुढे जा.
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students text column पर date parameter से filter लगाते हैं और उन्हें कोई row नहीं मिलती या errors आते हैं. पक्का करो कि column और parameter का type एक जैसा हो (Date vs Date/Time). Incremental refresh के लिए Date/Time इस्तेमाल करो और >= RangeStart और < RangeEnd से filter लगाओ, ताकि कोई row दो बार न गिनी जाए. एक बार फिर करके देखो, फिर आगे बढ़ो.