cancel
Showing results for
Did you mean:
Helper I

## calculate COUNTROWS by filtering using a column of categories

Hello Power BI Community,

I am trying to write a dax column that calculates the COUNTROWS based on the categories in a different column. See the data at he end.

Column = (CALCULATE(COUNTROWS('tableName'),FILTER('tableName','tableName'[categories])))

I know the filter expression is wrong. But my intent is to countrows for each category separately.

Any ideas are greatly appreciated. TIA
 name categories count c blue 10 y blue 10 y blue 10 v blue 10 i blue 10 o blue 10 r blue 10 f blue 10 a blue 10 t blue 10 r orange 9 f orange 9 a orange 9 t orange 9 g orange 9 c orange 9 y orange 9 y orange 9 v orange 9 a red 11 t red 11 g red 11 c red 11 y red 11 y red 11 v red 11 i red 11 o red 11 r red 11 f red 11 v yellow 10 i yellow 10 o yellow 10 r yellow 10 f yellow 10 a yellow 10 t yellow 10 g yellow 10 c yellow 10 y yellow 10
1 ACCEPTED SOLUTION
Super User

Hello @SriKandimalla ,
If  I understand your issue, try this:

``Countrows = CALCULATE(COUNTROWS(crow),ALLEXCEPT(crow,crow[categories]))``

crow is my table name.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Proud to be a Super User!

Super User

Hello @SriKandimalla ,
If  I understand your issue, try this:

``Countrows = CALCULATE(COUNTROWS(crow),ALLEXCEPT(crow,crow[categories]))``

crow is my table name.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Proud to be a Super User!

Announcements

#### Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

#### Power BI March 2023 Update

Find out more about the March 2023 update.

#### March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors
Top Kudoed Authors