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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
youconnect
Helper I
Helper I

Countrows IF

Hi,

Here my table:

 

Outcome expected: 3
I want Count Rows if id3=3 but alone. If I have id2 with id3 = 2 or 3 I don't want count these. I only want count if id3 = 3 and it's alone in id2.

 

Can you help me?

 

Thanks

1 ACCEPTED SOLUTION

@youconnect 

The cleanest way I can think of doing this is as a calculated column added to your table.

Count = 
VAR RowIDTwo = 'Table'[id2]
VAR IDTwoCount = CALCULATE(COUNTROWS('Table'),ALL('Table'),'Table'[id2]=RowIDtwo)
RETURN IF ( 'Table'[id3] = 3 && IDTwoCount = 1, 1, BLANK())

id3count.jpg

View solution in original post

4 REPLIES 4
youconnect
Helper I
Helper I

I mean alone if the value 3 it's not present in id3 column with value 2. See in the cloumn id2 I have the 20 value with values 2,2,3 in the id3 column. In thise case I don't want count the 3 value.

In my case the expected value is 3 because it's count of lines 6,15 and 20

Thanks @jdbuchanan71 

@youconnect 

The cleanest way I can think of doing this is as a calculated column added to your table.

Count = 
VAR RowIDTwo = 'Table'[id2]
VAR IDTwoCount = CALCULATE(COUNTROWS('Table'),ALL('Table'),'Table'[id2]=RowIDtwo)
RETURN IF ( 'Table'[id3] = 3 && IDTwoCount = 1, 1, BLANK())

id3count.jpg

Worked like a charm.

Many Thanks @jdbuchanan71 

jdbuchanan71
Super User
Super User

Hello @youconnect 

What do you mean by "alone" in ID2?  Do you mean if ID2 is empty?  In your screen shot, which rows should be counted?

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.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors