robH
August 22, 2019, 1:11pm
1
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
BrianJ
August 22, 2019, 1:22pm
2
@robH ,
If product code is a text field, I think the LEFT function may work for you here:
Learn more about: LEFT
robH
August 22, 2019, 3:01pm
3
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
robH
August 22, 2019, 4:24pm
5
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] )
robH
August 22, 2019, 5:00pm
6
all sorted- I had an issue with the appended tables- thanks Guys!