1. Lighthouse

Level 3 · Several filters at once, and IN

The request

From Kevin Park, B2B Account Lead

“Business customers buy on our website and in the app, and marketplace orders go through a reseller I don't manage. I need my own number per category: completed sales to business customers, web and app only. Marketplace stays out.”

Your goal

The matrix has products[category] on its rows and the given measure Sales (completed sales). Create a measure called Digital Business Sales: Sales for orders whose channel is web or app (use IN { }) and whose customer segment is business.

  • Fill [Digital Business Sales] on every row of the visualnot done yet
  • The Total row right toonot done yet

Your measure

DAX
Visual
A matrix: rows = products[category]; values = [Sales], [Digital Business Sales]
Measures in the report
Sales = CALCULATE(SUM(order_items[line_total]), orders[status] = "completed")
Data pane: tables and columns
  • order_items order_item_id, order_id, product_id, quantity, unit_price, discount_pct, line_total
  • orders order_id, customer_id, order_date, status, channel, shipping_fee, coupon_code
  • products product_id, name, category, subcategory, unit_price, unit_cost, launched_on, is_active
  • customers customer_id, first_name, last_name, email, city, state, signup_date, segment, referral_source
  • returns return_id, order_item_id, returned_on, reason, refund_amount
  • Date Date, Year, Quarter, Month Number, Month, Year Month, Year Quarter, Day, Weekday Number, Weekday

Loading the editor…

    Visual[Digital Business Sales] fills in when you press Check
    The visual before your answer
    categorySalesDigital Business Sales
    Decor$822,667
    Furniture$1,393,164
    Kitchen$799,150
    Lighting$1,001,844
    Outdoor$1,297,802
    Textiles$579,658
    Total$5,894,284

    Mote checks your result

    Press Check. Mote fills in your answer and compares it with what the report needs.

    The lesson

    Real tickets rarely need one filter. Kevin’s number has two conditions, on two tables: the order’s channel and the customer’s segment.

    What you are working in

    This is a practice DAX engine built for this site, not Power BI; it fills the matrix cell by cell with your measure and checks each cell. In Power BI Desktop: Home → New measure, type the formula (Shift+Enter starts a new line in the formula bar), press Enter, and add the measure to the matrix.

    Several filter arguments mean AND

    Digital Business Sales =
    CALCULATE(
        [Sales],
        orders[channel] IN { "web", "app" },
        customers[segment] = "business"
    )

    CALCULATE applies every filter argument at once. A row of order_items counts only if its order is web or app and its customer is a business. Filters on different columns never cancel each other; they intersect.

    IN { } for a list of values

    orders[channel] IN { "web", "app" } keeps the rows whose channel is any of the listed values. The curly braces build a small one-column table. It is the same as writing orders[channel] = "web" || orders[channel] = "app", and it reads better as the list grows. To exclude instead, wrap it: NOT ( orders[channel] IN { "marketplace" } ).

    OR inside one column, AND across columns

    A single boolean filter argument may test columns of one table only, and no measures. Inside it you can use ||, && and IN freely. To combine two tables with OR (web orders or business customers), you need a table filter, which comes in the next level with FILTER. Combining conditions with AND is easy: give each its own argument, as here.

    Filters travel along relationships

    customers[segment] lives in customers, not in orders. That’s fine: the filter lands on customers, the relationship carries it to orders, and the next one to order_items, where the sum runs. The Sales measure adds its own status filter inside, so the result is completed sales only. Nested CALCULATEs simply add up their filters.

    Common mistakes

    • && on the same column. orders[channel] = "web" && orders[channel] = "app" asks for orders that are both at once: none.
    • Case and spelling. Text matches ignore case in DAX, so "Web" works, but "website" matches nothing.
    • Filtering the visual instead. A channel slicer would also change the Sales column. Kevin wants both numbers side by side, so the filter belongs inside the measure.

    Pick what may run on this site. You can change this any time from "Cookie settings" at the bottom of every page.