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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Countrows with multiple criteria

Hello everyone,

Thank you for your time, I'm struggling creating a measure, hopefully you guys can help me.
Basically it's a countifs in excel but I just can make it work in DAX. Here's an example in excel:

Measure.PNG

 

I need to replicate that in PBI (Measure, column in light blue). The problem is that I can't make it count each variable in the columns that I'm using, here's what I have so far:

measure =
COUNTROWS(
SUMMARIZE(
ALL('Table'),
'Table'[Customer ID],
'Table'[Date]
)

I tried using the grouby option but it would take away other columns that I need after this gets done. I highly appreciate any help given! Thank you for your time!

1 ACCEPTED SOLUTION
DavisBI
Solution Specialist
Solution Specialist

Hi, @Anonymous ,

 

In this case you need to use EARILER().  (see screenshot below)

 

20201022103906.png

 

Column = 
CALCULATE (
    COUNT ( Sheet1[Date] ),
    'Sheet1'[Customer ID] = EARLIER ( Sheet1[Customer ID] ),
    'Sheet1'[Date] = EARLIER ( Sheet1[Date] ),
    ALL ( Sheet1 )
)

Mark this post as solution if this helps,thanks! 

View solution in original post

3 REPLIES 3
saumitra
Helper I
Helper I

Hi @DavisBI

I also have a similar problem, however I am not getting the desired outcome from the solution that you provided. I am attaching a screenshot, kindly please take a look at it. 

saumitra_0-1614155336290.png

So what I want is that, if Ash's name pops up for the first time for Forbes then the count should be 1. However, if it again pops up for the same company i.e. Forbes for Ash, then I want it to count as 2, as it is coming for the 2nd time and so on. 

I am attaching an excel sample also, for you to understand what excel formulae I am using. 

saumitra_1-1614155479296.png

saumitra_2-1614155516660.png

saumitra_3-1614155549371.png

I hope this helps. Kindly please help. I am also open to alternate solutions.

Thank you,

Regards,

Saumitra Upadhyaya

 

DavisBI
Solution Specialist
Solution Specialist

Hi, @Anonymous ,

 

In this case you need to use EARILER().  (see screenshot below)

 

20201022103906.png

 

Column = 
CALCULATE (
    COUNT ( Sheet1[Date] ),
    'Sheet1'[Customer ID] = EARLIER ( Sheet1[Customer ID] ),
    'Sheet1'[Date] = EARLIER ( Sheet1[Date] ),
    ALL ( Sheet1 )
)

Mark this post as solution if this helps,thanks! 

Anonymous
Not applicable

Davis!

Thank you so much for your help! This is exactly what I was looking for!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors