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
wagrezy
Helper I
Helper I

Apply String Filter on Calculate

Hi

I would like to create a formula which can apply a string filter on CALCULATE.

For instance, I would like to sum all units where names include the string "Rab", I was thinking of the following formula but wonder if there is a more optimised solution, many thanks for your help:

 

=CALCULATE(SUM([Units]),OR(OR([Name]="Rabbit",[Name]="Rab/Cat"),[Name]="Rab/Dog"))

 

Datatable:

 

Name          Units

Rabbit         4

Turtle          2

Dog            3

Cat              1

Rab/Cat      5

Rab/Dog     4

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@wagrezy Please try search or containstring function to get the desired output. 

 

Measure = CALCULATE(SUM('Table'[units]),SEARCH("Rab",'Table'[Name],1,0)>0)

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@wagrezy Please try search or containstring function to get the desired output. 

 

Measure = CALCULATE(SUM('Table'[units]),SEARCH("Rab",'Table'[Name],1,0)>0)

 

Works perfectly, thank you!

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.