Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, could anybody help me with DAX measure.
Lets say I have one Table with two columns:
TABLE: ID, Text
I would like to count allrows which includes certain string in Text field. String can be anywhere in the row not only at the beginning so in SQL %text_string%.
Is there any simple way to achieve aforedescribed?
Thanks
Solved! Go to Solution.
The SEARCH function allows you to search for a specific string within another string. You can use a combination of CALCULATETABLE, DISTINCTCOUNT, and the SEARCH function, to count the number of occurrences:
CntRows = CALCULATETABLE(ROW("rows",DISTINCTCOUNT(Table1[Text])),FILTER(ALL(Table1[Text]),SEARCH("text_string",Table1[Text],1,0)))
There are more similar examples here:
http://sqlblog.com/blogs/marco_russo/archive/2011/12/30/string-comparison-in-dax.aspx
Thanks,
Sam Lester (MSFT)
The SEARCH function allows you to search for a specific string within another string. You can use a combination of CALCULATETABLE, DISTINCTCOUNT, and the SEARCH function, to count the number of occurrences:
CntRows = CALCULATETABLE(ROW("rows",DISTINCTCOUNT(Table1[Text])),FILTER(ALL(Table1[Text]),SEARCH("text_string",Table1[Text],1,0)))
There are more similar examples here:
http://sqlblog.com/blogs/marco_russo/archive/2011/12/30/string-comparison-in-dax.aspx
Thanks,
Sam Lester (MSFT)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
88 | |
63 |