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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
hulk_deka
Frequent Visitor

CHOOSING ROWS WITH PARTICULAR VALUE.

i have two columns with the following values

col A  col B

a         1

b         2

c         2

d         1

e         2

 

I would like to have a count from column B with rows that have only '2' as an entry.

I.E in this case 3 is the answer i am looking for

i have been using this formula : 

M = COUNTROWS(Query1,Query1[col B]="2")
 
but it doesnt seem to work. 
Looking forward to some insights.
Rishav 

 

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

Hi @hulk_deka ,

According to your description, here's my solution. 

Create a measure.

M =
COUNTROWS ( FILTER ( 'Query1', 'Query1'[col B] = 2 ) )

Get the result. 

vkalyjmsft_0-1661930040936.png

As you say "column B with rows that have only '2' as an entry", I'm not sure if you mean for example the below sample, the 2 of e should not be included, as it still as a value 1. 

vkalyjmsft_1-1661930188149.png

If this is the case, modify the formula to:

Measure =
CALCULATE (
    DISTINCTCOUNT ( Query1[col A] ),
    FILTER (
        'Query1',
        COUNTROWS (
            FILTER (
                'Query1',
                'Query1'[col A] = EARLIER ( 'Query1'[col A] )
                    && 'Query1'[col B] <> 2
            )
        ) = 0
    )
)

Get the correct result according to the modified sample.

vkalyjmsft_2-1661930494869.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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
v-yanjiang-msft
Community Support
Community Support

Hi @hulk_deka ,

According to your description, here's my solution. 

Create a measure.

M =
COUNTROWS ( FILTER ( 'Query1', 'Query1'[col B] = 2 ) )

Get the result. 

vkalyjmsft_0-1661930040936.png

As you say "column B with rows that have only '2' as an entry", I'm not sure if you mean for example the below sample, the 2 of e should not be included, as it still as a value 1. 

vkalyjmsft_1-1661930188149.png

If this is the case, modify the formula to:

Measure =
CALCULATE (
    DISTINCTCOUNT ( Query1[col A] ),
    FILTER (
        'Query1',
        COUNTROWS (
            FILTER (
                'Query1',
                'Query1'[col A] = EARLIER ( 'Query1'[col A] )
                    && 'Query1'[col B] <> 2
            )
        ) = 0
    )
)

Get the correct result according to the modified sample.

vkalyjmsft_2-1661930494869.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Use this one 

= List.Count(List.Select(Query1[col B], each _=2 or _="2"))

 

is there any way we can use it as a measure? the above formula doesnt seem to be accepted as a measure and gives out an error.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.