Forum Discussion

SophieM's avatar
SophieM
New Member
1 year ago
Solved

Filter contains

Hello,

 

I am very new in Power BI and I am trying to learn it by myself.

I tried to create a new measure in the visual, to filter one column and to show just the rows where the column contains a certain text.

However it is not working. Can you please take a look, am I missing something? thank you

 

= FILTER(Cars,CONTAINSSTRING(Cars[ID],"SM"))
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi SophieM ,

     

    Measure is typically a calculation that returns a value. If you want to filter rows in a visual, you need to use the Filter.

    In addition, your DAX return result is a table, and you can also use it to create a custom table and get the same result.

     

     

     

     

     

    ——————————————————————————————————————————————————

    If my answer helps you solve the problem, please accept my answer as a solution and let it be seen by more people in need.

     

    Best regards,

    Mengmeng Li

4 Replies

  • SophieM 

    The FILTER function is typically used in calculated columns or tables, not measures. Measures are used to perform calculations on data, and they return a single value rather than a table.

    To achieve your goal, you can create a calculated column or use a visual-level filter.

     

    DAX
    FilteredColumn = IF(CONTAINSSTRING(Cars[ID], "SM"), Cars[ID], BLANK()) 

     

     

    If you still want to use a measure, you can create a measure that counts the rows where the condition is met:

    FilteredCount = CALCULATE(COUNTROWS(Cars), CONTAINSSTRING(Cars[ID], "SM"))
    This measure will count the number of rows where Cars[ID] contains "SM". You can then use this measure in your visual to display the count.

    • SophieM's avatar
      SophieM
      New Member

      thank you very much, I will try it

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi SophieM ,

     

    Measure is typically a calculation that returns a value. If you want to filter rows in a visual, you need to use the Filter.

    In addition, your DAX return result is a table, and you can also use it to create a custom table and get the same result.

     

     

     

     

     

    ——————————————————————————————————————————————————

    If my answer helps you solve the problem, please accept my answer as a solution and let it be seen by more people in need.

     

    Best regards,

    Mengmeng Li