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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Bastienlin_
Helper II
Helper II

How to count if at least one value meets criteria, then add to a count

Hello,

Here is an example of a sample of my data:

CityQuestionAnswer
Paris1Yes
Paris2Yes
Paris3Yes
London1Yes
London2No
London3No
Madrid1Yes
Madrid2Yes
Madrid3No

 

I need to count the distinct number of countries that has at least one "No" as answer in the selected questions (Here, question 1, 2 & 3).

The output should be 2 there, for London and Madrid having at least one "No" for these questions.

Thank you for your help !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Bastienlin_ ,

Please try to create a measure with below dax formula and add it to card visual

Measure =
VAR tmp =
    SUMMARIZE (
        'Table',
        'Table'[City],
        'Table'[Answer],
        "Count NB", COUNT ( 'Table'[Question] )
    )
VAR tmp1 =
    FILTER ( tmp, [Answer] = "No" && [Count NB] >= 1 )
RETURN
    COUNTROWS ( tmp1 )

vbinbinyumsft_0-1663638622616.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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

3 REPLIES 3
Anonymous
Not applicable

Hi @Bastienlin_ ,

Please try to create a measure with below dax formula and add it to card visual

Measure =
VAR tmp =
    SUMMARIZE (
        'Table',
        'Table'[City],
        'Table'[Answer],
        "Count NB", COUNT ( 'Table'[Question] )
    )
VAR tmp1 =
    FILTER ( tmp, [Answer] = "No" && [Count NB] >= 1 )
RETURN
    COUNTROWS ( tmp1 )

vbinbinyumsft_0-1663638622616.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @Anonymous, thank you for your answer.

I also tried in parallel a formula and I think it works too:

Measure = CALCULATE(DISTINCTCOUNT(Table[City]), FILTER(ALL(Table),[Question] in {"1", "2", "3",}),Table[Answer] = "No")

This measure seems simplier, what do you think ?

Best regards,
Bastien
Anonymous
Not applicable

Hi @Bastienlin_ ,

For measure, the simpler the better, as long as you are sure to get the right result.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors