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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Socrates
Frequent Visitor

Count Rows by multiple conditions

Hello

 

I'm having the below problem I just can't seem to get my head around. I know the solution is simple but I'm having a complete mental block as to what it could be.

 

Data is set out like:

 

Number PlateSite
NP 1Site 1
NP 2Site 2
NP 3Site 3
NP 4Site 1
NP 1Site 2
NP 2Site 1
NP 2Site 3
NP 1Site 1
NP 3

Site 1

NP 4

Site 1

 

I'd like to count the number plates that have parked at more that one site (could be two, could be all three), ignoring those that have only parked at one (even multiple times). So I'd have an output matrix (or any other visual) like this:

 

Number PlateSite 1Site 2Site 3
NP 121 
NP 2111
NP 31 1

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I have used the following logic:

more than 2 sites = 
VAR __validation = IF( CALCULATE( DISTINCTCOUNT('Table'[Site]); ALL( 'Table'[Site])) > 1; TRUE(); FALSE())

RETURN
    IF(
        __validation;
        COUNTROWS( 'Table');
        BLANK()
    )

Which returns the following matrix

test.PNG

If this also works for you then please mark it as the solution. Kudos is also appreciated Smiley Happy

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I have used the following logic:

more than 2 sites = 
VAR __validation = IF( CALCULATE( DISTINCTCOUNT('Table'[Site]); ALL( 'Table'[Site])) > 1; TRUE(); FALSE())

RETURN
    IF(
        __validation;
        COUNTROWS( 'Table');
        BLANK()
    )

Which returns the following matrix

test.PNG

If this also works for you then please mark it as the solution. Kudos is also appreciated Smiley Happy

Yes! That's it, thank you. I was doing similar but doing the count on the wrong column. 

AlB
Super User
Super User

Hi @Socrates 

You can just place Number Plate and Site in the rows and columns of a matrix visual and then place Site in values, selecting Count (i.e., implicit measure) or create an explicit measure and place it in values:

Measure = COUNT(Table1[Site])  

 

popov
Resolver III
Resolver III

Hello, @Socrates 

Create measure like this:

Count = COUNTROWS(<YourTableName>)
And add this measure in matrix, in rows place column Number Plate, in columns place column Site

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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