DAX | The FILTER function exercise | Use the FILTER function to limit purchases in a measure

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Software ==> DAX  (28 exercises)
Version ==>
Topic ==> The FILTER function  (1 exercise)
Level ==> Relatively easy
Subject ==> Power BI training
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Open the Power BI file in the above folder:

Dummy measure in matrix

At the moment the matrix shows a dummy measure.


The SUMX function uses this syntax:

The SUMX function

The table can be a table, or the set of rows returned from a FILTER function.  We'll create examples of both types of syntax!

Use this information to create a measure called Sales, which should sum the price multiplied by the quantity.  Show this measure in your matrix to give:

Sales by year and environment

You should see a report showing total sales by purchase year and environment.


Copy the formula for this measure, and use this as a basis to create a new measure called Sales in 2018.  This measure should use the FILTER function to only sum sales where the year for the purchase date is 2018.

You can use the YEAR function to return the year corresponding to any date.

Show this measure in the matrix to get the following;

Sales for 2018

The matrix collapses, as there are only figures for 2018.


Now copy the formula for this measure again and amend it to create another measure called Big sales 2018, which only sums sales where:

  • The purchase year is 2018; and
  • The quantity of goods bought for a purchase was 5 or more.

This should give the following table:

2018 big sales

The figures are falling, as we filter out more purchases.


You can use the AND function, the && operator or nested FILTER functions to achieve this - the choice (as Graham used to say) is yours!

Save this file as Special measures, then close it down.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 1 thread Add post
09 Apr 20 at 10:21

big sales = CALCULATE([total sales],FILTER('Purchase',AND(YEAR('Purchase'[PurchaseDate])=2018,Purchase[Quantity]>5)=TRUE()))


total sales = sumx('Purchase','Purchase'[Quantity]*Purchase[Price])

Why is this not working?

10 Apr 20 at 12:09

The quantity should be greater than or equal to 5, not greater than 5.  Failing that, compare your formula with the answer given?