Dax formula to filter results on product codes

So I have created a total sales measures that i want to add a filter on product codes. I have thousands of products, but they are grouped by the initial digits. the ones I want to pick out for instance all start with 009. I am new to DAX and was looking for a ‘starts with’ expression, but no such luck!

Thanks in Advance
Rob

@robH,

If product code is a text field, I think the LEFT function may work for you here:

https://docs.microsoft.com/en-us/dax/left-function-dax

Thanks for the help but I’m having trouble getting that to work as it doesn’t like the parameters. My original measure is:

Total Revenue = sum('Total Sales'[NetSalesValue] )

And I want to filter from ‘Total Sales’[StockCode], only items that start with 009, but the left function doesn’t allow me to point to a table.

Just to expand on what BrianJ said - try splitting the Stock Code column on the Left 3 characters.

Guy

Thanks Guy,

So I have created a new column in the table- which was easy as columns from examples picked it up then tried:

Stoves Sold = 
VAR
    StovesSold = FILTER('Total Sales', 'Total Sales'[Stock Group] = "009" )
    RETURN
    CALCULATE([Total Revenue], StovesSold )

But this isn’t returning any values- what am I missing?

Total Revenues = Total Revenue = sum(‘Total Sales’[NetSalesValue] )

all sorted- I had an issue with the appended tables- thanks Guys!