Forum Discussion
Like a COUNTIF in Excel
- 5 years ago
The general pattern is to use filters. (See also the recommendations links in the sidebar.)
CALCULATE ( COUNT ( Table1[Section] ), FILTER ( VALUES ( Table1[Section] ), CONTAINSSTRING ( Table1[Section], "G.CO.5" ) ) )Edit: Changed LEFT condition to CONTAINSSTRING.
The general pattern is to use filters. (See also the recommendations links in the sidebar.)
CALCULATE (
COUNT ( Table1[Section] ),
FILTER (
VALUES ( Table1[Section] ),
CONTAINSSTRING ( Table1[Section], "G.CO.5" )
)
)
Edit: Changed LEFT condition to CONTAINSSTRING.
- jaw198835 years agoFrequent Visitor
That is my problem is the depth of FILTER. If there is only 1 section listed, (G.CO.5 Tranasformations....) it is a simple, ="G.CO.5 Transformations in the Coordinate Plane" and it works.
My problem is that the section could be 1 of multiple in the data, and I do not know which order it will be in. for instance, the data in the Section column for a record could be:
G.CO.5 Transformations in the Coordinate Plane, G.CO.11 Parallelograms, SRT.5 Similar Triangles
OR
G.CO.11 Parallelograms, G.CO.5 Transformations in the Coordinate Plane, SRT.5 Similar TrianglesOR
G.CO.11 Parallelograms, SRT.5 Similar Triangles, G.CO.5 Transformations in the Coordinate Planedepending on when they enrolled in the section. Therefore, there is no pattern as to when the section will appear so I need to use a (*) to evaluate *G.CO.5 Transformations in the Coordinate Plane* wherever it may appear in the data string.
- AlexisOlson5 years agoSuper User
In that case, you can use CONTAINSSTRING ( Table1[Section], "G.CO.5" ) instead of the LEFT line.
- jaw198835 years agoFrequent Visitor
AlexisOlson That worked! Thank you! You also helped me start to see how the DAX logic works a bit differently. I look forward to understanding that more. Thanks again....