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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.