Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Apply Filter and Contains into Search

I am trying to apply a new measure that inculdes a Filter and a contains. i have the below code:
 
Techniques =
CALCULATE(
DISTINCTCOUNT( 'enterprise-attack'[url] ),
FILTER(
'enterprise-attack',[Value.x_mitre_platforms] in {"Windows","Linux","macOS"}
)
)
 
i need to add a CONTAINS for the URL field so if the URL Field CONTAINS "Techniques" as well as the other filter. 
  • Hi, Anonymous 

    Here you need to use function 'CONTAINSSTRING' rather than 'CONTAINS'.

    'CONTAINS' judges whether this value ‘https://attack.mitre.org/techniques/ ’ is equal to the value in the column, and 'CONTAINSSTRING' judges whether the value ‘https://attack.mitre.org/techniques/ ’ is part of the value  in the column.

     

    Please change your measure as below:

     

    Techniques = 
    CALCULATE(
    DISTINCTCOUNT( 'enterprise-attack'[url] ),
    FILTER('enterprise-attack',[Value.x_mitre_platforms] in {"Windows","Linux","macOS"} && CONTAINSSTRING('enterprise-attack'[Url],"https://attack.mitre.org/techniques/"))
    )​

     


     CONTAINSTRING VS. CONTAINS

     

     

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

     

3 Replies

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    Anonymouscan you try this

    FILTER(
    'enterprise-attack',[Value.x_mitre_platforms] in {"Windows","Linux","macOS"} && CONTAINS())

     

    if it does not work please provide a sample data

    • Anonymous's avatar
      Anonymous
      Not applicable

      I have tried 

       

      Techniques =
      CALCULATE(
      DISTINCTCOUNT( 'enterprise-attack'[url] ),
      FILTER('enterprise-attack',[Value.x_mitre_platforms] in {"Windows","Linux","macOS"} && CONTAINS('enterprise-attack','enterprise-attack'[url],"https://attack.mitre.org/techniques/"))
      )
       
      i have attached a screenshot example.
  • v-easonf-msft's avatar
    v-easonf-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

    Here you need to use function 'CONTAINSSTRING' rather than 'CONTAINS'.

    'CONTAINS' judges whether this value ‘https://attack.mitre.org/techniques/ ’ is equal to the value in the column, and 'CONTAINSSTRING' judges whether the value ‘https://attack.mitre.org/techniques/ ’ is part of the value  in the column.

     

    Please change your measure as below:

     

    Techniques = 
    CALCULATE(
    DISTINCTCOUNT( 'enterprise-attack'[url] ),
    FILTER('enterprise-attack',[Value.x_mitre_platforms] in {"Windows","Linux","macOS"} && CONTAINSSTRING('enterprise-attack'[Url],"https://attack.mitre.org/techniques/"))
    )​

     


     CONTAINSTRING VS. CONTAINS

     

     

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