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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ScarlettBebb
Frequent Visitor

COUNTROWS Calculation not working for Multiple filters.

Hello, 

 

Thank you so much in advance if you response to this. I am trying to create a Count Rows column or Measure it doesn't matter which for this. I need to count the number of rows as a way of calucating the number of tested products/Lots per Month. I have a Date column called 'Attribute', A Product column, and a Lot column. This is an example of my Table. 

 

ProductLotAttributeVerdict
G111105-Jan-161
G111212-Feb-161
G111304-Mar-161
G111408-Apr-160
G111514-May-160
G111616-Jun-160
G111717-Jul-160
G111818-Aug-161
G111926-Sep-161
G222105-Jan-161
G222212-Feb-161
G222304-Mar-160
G222408-Apr-160
G222514-May-160
G222616-Jun-161
G222717-Jul-161
G222818-Aug-161
G222926-Sep-161
G333105-Jan-161
G333212-Feb-161
G333304-Mar-160
G333408-Apr-160
G333514-May-160
G333616-Jun-161
G333717-Jul-161
G333818-Aug-161
G333926-Sep-161

 

I am trying to caluclate the number of tested batches by Product and Lot over 1 month per year using this formula which is not working. 

 

Number of tested = COUNTROWS(
    FILTER('FPA data combined'),
    FILTER('FPA data combined'[Attribute],
    FILTER('FPA data combined'[Product ],
    FILTER('FPA data combined'[Lot]))
    ))
 
Thank you so much,
 
Scarlett
1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

@ScarlettBebb , you can try this calculated column formula:

Column =
VAR product = 'Table'[Product]
VAR lot = 'Table'[Lot]
VAR month = MONTH ( 'Table'[Attribute] )
VAR year = YEAR ( 'Table'[Attribute] )
VAR t =
    FILTER (
        'Table',
        'Table'[Product] = product && 'Table'[Lot] = lot
            && MONTH ( 'Table'[Attribute] ) = month && YEAR ( 'Table'[Attribute] ) = year
    )
RETURN
    COUNTROWS ( t )

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

4 REPLIES 4
ERD
Community Champion
Community Champion

Hi @ScarlettBebb , do you have a separate Date table in your model? What are you trying to filter?

 

ERD_0-1693306352436.png

Measure = COUNTROWS('Table')

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hello @ERD I have a date column in table. I am trying to count the numbers of Products tested per month so I have filtered 'Product' and the 'Lot' and then was trying the filter 'Date to 1 month'. So my new column should look like the one below 'Numbers Tested'. 

 

ProductLotAttributeVerdictNumbers Tested
G111105-Jan-1611
G111212-Feb-1611
G111304-Mar-1611
G111408-Apr-1601
G111514-May-1601
G111616-Jun-1601
G111717-Jul-1601
G111818-Aug-1611
G111926-Sep-1611
G222105-Jan-1611
G222212-Feb-1611
G222304-Mar-1601
G222408-Apr-1601
G222514-May-1601
G222616-Jun-1611
G222717-Jul-1611
G222818-Aug-1611
G222926-Sep-1611
G333105-Jan-1611
G333212-Feb-1611
G333304-Mar-1601
G333408-Apr-1601
G333514-May-1601
G333616-Jun-1611
G333717-Jul-1611
G333818-Aug-1611
G333926-Sep-1611
ERD
Community Champion
Community Champion

@ScarlettBebb , you can try this calculated column formula:

Column =
VAR product = 'Table'[Product]
VAR lot = 'Table'[Lot]
VAR month = MONTH ( 'Table'[Attribute] )
VAR year = YEAR ( 'Table'[Attribute] )
VAR t =
    FILTER (
        'Table',
        'Table'[Product] = product && 'Table'[Lot] = lot
            && MONTH ( 'Table'[Attribute] ) = month && YEAR ( 'Table'[Attribute] ) = year
    )
RETURN
    COUNTROWS ( t )

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

@ERD Thank you so much that worked perfectly 🙂

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors