Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
yippiekyoo
Frequent Visitor

Filter measure "starts with"

Hi All,

 

working currently on a project where I need to filter certain values from a database in order to categorize them. 

 

I need to have a measure that says filter all part numbers starting with the letter A. 

 

Thats my current function:

Filter function =
SUMX(
FILTER(
'AO Domestic',
'AO Domestic'[Part Number] = "STARTS WITH A"
)
,
'AO Domestic'[Total Actual Cost incl. Retro. Pay])

 

Would be great if someone could tell me how to correct the measure. Thanks a lot in advance.

 

Kind regards

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

you can write your measure like so

Measure 3 = 
CALCULATE(
	SUM('FactWithDates'[Amount])
	,FILTER(
		'FactWithDates'
		,LEFT('FactWithDates'[Item],1) ="A"
	)
) 

Hopefully this gets you started

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
Heinrich
Post Patron
Post Patron

Hello @TomMartens 
This solution is great.

Can this measure be used to filter and leave only the alphabetical rows.

Means filter out everything that start with A to Z
Regards

Heinrich

Hey @Heinrich ,

 

you can adapt the measure like so:

Measure 3 = 
CALCULATE(
	SUM('FactWithDates'[Amount])
	,FILTER(
		'FactWithDates'
		,LEFT('FactWithDates'[Item],1) in { "A", "B", "C" }
	)
) 

The curly braces define a table. Of course you can define a table in your semantic model that contains the rows A-Z, then the filter statement will look like this:

...
,LEFT('FactWithDates'[Item],1) in VALUES( 'tablename'[columnname] )
...

Hopefully this will help to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens 

Thank you very much.

Have a great weekend.

Regards

Heinrich

TomMartens
Super User
Super User

Hey,

 

you can write your measure like so

Measure 3 = 
CALCULATE(
	SUM('FactWithDates'[Amount])
	,FILTER(
		'FactWithDates'
		,LEFT('FactWithDates'[Item],1) ="A"
	)
) 

Hopefully this gets you started

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi thank you very much  - that works. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.