Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

LIKE function in a measure

How to use a function that does the same thing as, for example, I want to do a calculation where I want only one group of information in a given field to be considered:
Global Efficiency =
CALCULATE (
'IndicatorValue' [Value AVG];
TREATS ({("Global (%)")}; 'Indicator' [Description]); Equipment [DescriptionL1] = "L1_ *")

  • Hi Anonymous,

     

    The LIKE operators in SQL has a similar correspondent function in DAX: the SEARCH function has a slightly different semantic because it returns the position found instead of a True/False value.

     

    For example, consider the following condition in SQL:

    Name LIKE '%SQLBI%Methodology%at%work%'

    The correspondent syntax in DAX is:

    SEARCH( "SQLBI*Methodology*at*work", Table[Name], 1, 0 ) > 0

    There are more similar examples here:

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

     

    Regards

2 Replies

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Microsoft Employee

    Hi Anonymous,

     

    The LIKE operators in SQL has a similar correspondent function in DAX: the SEARCH function has a slightly different semantic because it returns the position found instead of a True/False value.

     

    For example, consider the following condition in SQL:

    Name LIKE '%SQLBI%Methodology%at%work%'

    The correspondent syntax in DAX is:

    SEARCH( "SQLBI*Methodology*at*work", Table[Name], 1, 0 ) > 0

    There are more similar examples here:

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

     

    Regards

    • labuserMiles's avatar
      labuserMiles
      New Member

      how about what you wanna search is dynamic. just like a search engine you can type anything in the search box(slicer)