29. Practice Exercises and Final Assignment
29.4 Module 8: Add Column, Calculated Columns and Measures
- Use Column From Examples to create First Name from Customer Name.
- Create a Custom Column Order Line Total handling null Discount with
??. - Write
fnDeliveryBandand call it with Invoke Custom Function in both the Blinkit and Amazon Now queries. - Add an Index column starting at 1001 with increment 1.
- Parse a JSON Drop Location column into lat, lng and area.
- Create 5-minute delivery buckets with Standard › Integer-Divide and Multiply.
- Add Order Date, Order Hour and Day Name using Date and Time menus.
- DAX calculated columns: Category (RELATED), Delivery Speed Band (SWITCH) with a sort column, Is Weekend in the Date table.
- Implement Net Sales both as a column + SUM and as a SUMX measure. Compare results and model size.
- Explain why "% Under 10 Mins" must be a measure.
- Create a
_Measurestable, display folders and ₹ formats. Add a dynamic format string for Total Sales.
Practice files (fictional): column_vs_measure_orders.csv, pq_customers_text.csv, visuals_orders_apr_may_2026.csv
Hints
- Add Column keeps originals; DAX columns are evaluated at refresh, measures at query time.
Solutions (checked on the practice files)
- Ravindra, Shraddha, Ruhi, Salman.
[Amount] - ([Discount] ?? 0)oncolumn_vs_measure_orders.csv→ 450, 300, 600, 400, 0 = ₹1,750.- Bands: Within 10 min 2 (201, 203), 11-20 min 2 (202, 204), Not delivered 1 (205).
- Add Column › Index Column › Custom › Starting index 1001, increment 1 → 1001…1005.
- Parse › JSON, then expand lat, lng, area (fields depend on your sample).
- Integer-Divide 5 then Multiply 5: 5, 10, 5, 15, null.
- Visuals file: 06-Apr-2026 = Monday, 05-May-2026 = Tuesday.
- RELATED needs a many-to-one relationship; SWITCH(TRUE(), …) for bands; add a numeric sort column and use Sort by column.
- Both give ₹1,750 on the practice file; the column adds stored data (larger model), the SUMX measure does not.
- Ratios must be recalculated for each filter: on the file, % under 10 = 2 ÷ 4 delivered = 50% – averaging row percentages would be wrong.
- _Measures table, display folders, Currency ₹ English (India); dynamic format string returns e.g. "₹#,0,.0K" above 1,000.
Ravindra Bagale's Tip
Friends, many students check a measure only in the grand total. Test every measure in a table visual by City and by Month, and compare one or two cells with a manual calculation. Keep this in mind!
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students measure फक्त grand total मध्येच चेक करतात. प्रत्येक measure City नुसार आणि Month नुसार table visual मध्ये test करा, आणि एक-दोन cells हाताने केलेल्या calculation शी जुळवून बघा. लक्षात ठेवा!
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students measure को सिर्फ़ grand total में check करते हैं. हर measure को City और Month के हिसाब से table visual में test करो, और एक-दो cells को हाथ से किए calculation से मिलाओ. ध्यान रखना!