Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
JWPowder
Frequent Visitor

Count rows where a column of combined values contains a specific text

Hello, I have column of 3 letter defect codes in a QC data tracker table. These values are combined when they are entered into the PowerApp I use to records the data. 

 

I am now trying to create a pareto chart pf the top 3-letter defect codes in a given period. I am stuck on the measure to count if the column contains a specific defect code. 

 

There are over 20 different defect codes I will have to write measures to count. 

 

I have tried several of the DAX responses on previous posts with no avail. Examples below: 

 

APP Count = COUNTROWS (
    FILTER ( HILLIARDQCDATA, CONTAINSSTRING ( HILLIARDQCDATA[Defect Code(s)], "APP," ) )
)

 

Countif:=CALCULATE(
COUNTROWS(Table),
SEARCH("a",Table[names],,0))

 

Data: 

Table of Defect Codes:

JWPowder_0-1716902491492.png

 

Column I need to count is Defect Code(s):

JWPowder_1-1716902523369.png

 

Any help or tips are very much appreciated. 

 

Thank you in advance!

1 ACCEPTED SOLUTION
v-yifanw-msft
Community Support
Community Support

Hi @JWPowder ,

Based on your question, you can follow the measure below.

Sample data:

vyifanwmsft_0-1717402980161.png

Add a new measure:

SDS COUNT = 
VAR _ture_or_false =
    CONTAINSSTRING ( SELECTEDVALUE ( 'Table (2)'[Defect Code(s)] ), "SDS" )
VAR _text_app =
    IF ( _ture_or_false = TRUE (), 1, 0 )
RETURN
    CALCULATE ( COUNTROWS ( 'Table (2)' ), FILTER ( 'Table (2)', _text_app = 1 ) )
RESULT = SUMX('Table (2)','Table (2)'[SDS COUNT])

Final output:

vyifanwmsft_1-1717403480520.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yifanw-msft
Community Support
Community Support

Hi @JWPowder ,

Based on your question, you can follow the measure below.

Sample data:

vyifanwmsft_0-1717402980161.png

Add a new measure:

SDS COUNT = 
VAR _ture_or_false =
    CONTAINSSTRING ( SELECTEDVALUE ( 'Table (2)'[Defect Code(s)] ), "SDS" )
VAR _text_app =
    IF ( _ture_or_false = TRUE (), 1, 0 )
RETURN
    CALCULATE ( COUNTROWS ( 'Table (2)' ), FILTER ( 'Table (2)', _text_app = 1 ) )
RESULT = SUMX('Table (2)','Table (2)'[SDS COUNT])

Final output:

vyifanwmsft_1-1717403480520.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors