cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
doubleclick
Helper I
Helper I

Dax Measure where calculate & sum are used, but want to filter table if a column contains a string

Hey all, I have a simple DAX formula in Excel Powerpivot (NOT pbi)

 

=calculate(sum(table[Sales])

 

I want to filter it so that if [X Column] contains the string "pablo", only then will the sum be calcaulted. 

 

I've tried a bunch of different methods 

For some reason 'containsstring' is not a function available

1 ACCEPTED SOLUTION
BeaBF
Super User
Super User

@doubleclick Try:

=
CALCULATE (
    sum(table[Sales]),
    FILTER (table, FIND ( "Pablo", Table[X Column],, 0 ) <> 0 )
)

Note that the function FIND is case-sensitive. Check this link for details:

https://www.sqlbi.com/articles/from-sql-to-dax-string-comparison/

B.

View solution in original post

1 REPLY 1
BeaBF
Super User
Super User

@doubleclick Try:

=
CALCULATE (
    sum(table[Sales]),
    FILTER (table, FIND ( "Pablo", Table[X Column],, 0 ) <> 0 )
)

Note that the function FIND is case-sensitive. Check this link for details:

https://www.sqlbi.com/articles/from-sql-to-dax-string-comparison/

B.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors