Forum Discussion

jakeryan56's avatar
jakeryan56
Advocate II
9 years ago
Solved

SUM filter if contains text - Issue

Hi,   I am trying to calculate SUM of a field if another field contains a value. I tried the following formulas but neither work:   I tried using a wildcard symbol (not sure if it works in DAX) ...
  • Anonymous's avatar
    Anonymous
    9 years ago

    jakeryan56,

    You could try something like this:

     

    Consumer Handset Plan =
    CALCULATE (
        SUM( 'Sales Data'[Qty] ),
        FILTER ( 'Sales Data', FIND ( "Mobile", 'Sales Data'[Plan Type],, 0 ) <> 0 )
    )

     

    Note that FIND is case-sensitive. Check this link for details on using FIND vs. SEARCH etc. - https://www.sqlbi.com/articles/from-sql-to-dax-string-comparison/

     

    You may also find it quite slow with large datasets.  If you want to use that 'category' of Plan Type for other reasons - e.g. adding a slicer for Plan Type Category, consider adding a conditional column for every row in Power Query when you get the data, using Text.Contains functions etc.