Forum Discussion

giovissimo's avatar
giovissimo
Icon for Helper I rankHelper I
5 years ago
Solved

Wildcard characters in filter expression

Hello,

I have a table including all the students enrolled in a university course, and need to obtain the number of those who attended certain schools (identified by the prefix "school").

To do so, all I need is to FILTER the "SchoolName" field inside a CALCULATE expression, in order to count only those values starting with the word "school", adding an asterisk as a wild character after the word "school". 

Therefore I wrote the following:

 

Students = CALCULATE([Students], FILTER(ALL(Course[SchoolName]),Course[SchoolName]="School*"))
 
but I get a null value.
What's wrong with my expression ?
 
Giovanni
  • giovissimo there is no concept of wildcard, you can do something like this

     

    Students = CALCULATE([Students], FILTER(ALL(Course[SchoolName]),LEFT(Course[SchoolName],5)="School"))
    
    Students = CALCULATE([Students], FILTER(ALL(Course[SchoolName]),CONTAINSSTRING(Course[SchoolName],"School"))

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

2 Replies

  • giovissimo there is no concept of wildcard, you can do something like this

     

    Students = CALCULATE([Students], FILTER(ALL(Course[SchoolName]),LEFT(Course[SchoolName],5)="School"))
    
    Students = CALCULATE([Students], FILTER(ALL(Course[SchoolName]),CONTAINSSTRING(Course[SchoolName],"School"))

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.