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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

Using a function Like or Search to calculate

Hi guys,

 

I have the following table:

NameValue
Car One100
Car Two150
Bike One10
Bike Two15
Bike Three20

 

What I want to do is to calculate all the values that correspond to a field that has the word "bike"in it and divide them by all: For example "Calculate(SUM(Table[Value]),  Table[Name]="Bike")  this calculation gives me the  values that

only use the word "Bike". As a result i would like to have (10+15+20)/(10+15+20+100+150).

1 ACCEPTED SOLUTION
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

You may create the measure with SEARCH Function.

Measure =
DIVIDE (
    SUMX (
        FILTER ( Table3, SEARCH ( "Bike", Table3[Name], 1, 0 ) > 0 ),
        Table3[Value]
    ),
    SUM ( Table3[Value] )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

You may create the measure with SEARCH Function.

Measure =
DIVIDE (
    SUMX (
        FILTER ( Table3, SEARCH ( "Bike", Table3[Name], 1, 0 ) > 0 ),
        Table3[Value]
    ),
    SUM ( Table3[Value] )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a New Measure

 

Test171 = 
VAR _BikeSum = SUMX(FILTER(ALL(Test171PatternMatchSum),LEFT(Test171PatternMatchSum[Name],4)="Bike"),Test171PatternMatchSum[Value])
VAR _Total = SUM(Test171PatternMatchSum[Value])
RETURN FORMAT(DIVIDE(_BikeSum,_Total),"#0.00")

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar

 

If you write "Car"instead the result will be 1 because it takes all the data that has n+ characters. So it will only work if the name is the longest.

@Anonymous The initial question that you have posted is to know the Total Sales that contains Bike in the text. 

 

Please post the appropriate test data and expected output to suggest an accurate solution.





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.