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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Marks9172
Regular Visitor

Count Column Instances of Number based on Multiple Cell Criteria

Customers are scanned multiple times a day and I need a way to count the number of occurences of a customer number on each day and for each product they one. I will then divide 1 by the number of occurrences based on matching the customer number, product and created at date fields to get an actionable field for calculating total visits.

 

Sample Table 

I am attaching an example table for reference and am trying to create the Admissions-Scanned column in my data table.  

I have tried multiple solutions but I am not getting the desired result. 


The excel formula I have used in the past is 

=IF(ISBLANK([@[Product Name]])=FALSE,1/COUNTIFS([Customer Number],[@[Customer Number]],[Product Name],[@[Product Name]],[Created At Date],[@[Created At Date]]),0)

 

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

Hi @Marks9172 ,

You can achieve your goal by creating a new calculated column by this DAX:

ADMISSIONS - SCANNED = 
IF (
    NOT ISBLANK('YourTable'[Product Name]),
    1 / CALCULATE(
        COUNTROWS('YourTable'),
        'YourTable'[Customer Number] = EARLIER('YourTable'[Customer Number]),
        'YourTable'[Product Name] = EARLIER('YourTable'[Product Name]),
        'YourTable'[Created At Date] = EARLIER('YourTable'[Created At Date])
    ),
    0
)

 

Your output will look like this:

Bibiano_Geraldo_1-1738318895487.png

 

 

View solution in original post

4 REPLIES 4
Bibiano_Geraldo
Super User
Super User

Hi @Marks9172 ,

You can achieve your goal by creating a new calculated column by this DAX:

ADMISSIONS - SCANNED = 
IF (
    NOT ISBLANK('YourTable'[Product Name]),
    1 / CALCULATE(
        COUNTROWS('YourTable'),
        'YourTable'[Customer Number] = EARLIER('YourTable'[Customer Number]),
        'YourTable'[Product Name] = EARLIER('YourTable'[Product Name]),
        'YourTable'[Created At Date] = EARLIER('YourTable'[Created At Date])
    ),
    0
)

 

Your output will look like this:

Bibiano_Geraldo_1-1738318895487.png

 

 

Thanks, this did the trick!

Anonymous
Not applicable

Hi, @Marks9172 


Thanks for reaching out to the Microsoft fabric community forum.

Regarding the issue you raised, my solution is as follows:

I might need to inform you that currently, I am unable to open the data you shared.

vlinyulumsft_0-1738308387830.png

 If you need to share data with us, I recommend using GitHub and ensuring that sensitive information is removed.

 

However, based on your description, I have created the following test data:

vlinyulumsft_1-1738308387832.png

And converted your Excel data into the following measures:

Admissions-Scanned = 
IF (
    NOT ( ISBLANK (MAX('Table'[Product Name] ) )),
    1 / CALCULATE (
        COUNTROWS ( 'Table' ),
        ALLEXCEPT('Table','Table'[Customer Number],'Table'[Created At Date],'Table'[Product Name])
    ),
    0
)

Here's my final result, which I hope meets your requirements.
 

vlinyulumsft_2-1738308450643.png

Please find the attached pbix relevant to the case.

Best Regards,

Leroy Lu

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

 

 

Thanks for the heads up on not being able to use the sample data set.  I will use my github repository next time.  I did test the solution and it seems to work.  Thanks again.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors