cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SriKandimalla
Helper I
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
namecategoriescount
cblue10
yblue10
yblue10
vblue10
iblue10
oblue10
rblue10
fblue10
ablue10
tblue10
rorange9
forange9
aorange9
torange9
gorange9
corange9
yorange9
yorange9
vorange9
ared11
tred11
gred11
cred11
yred11
yred11
vred11
ired11
ored11
rred11
fred11
vyellow10
iyellow10
oyellow10
ryellow10
fyellow10
ayellow10
tyellow10
gyellow10
cyellow10
yyellow

10

1 ACCEPTED SOLUTION
Nathaniel_C
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

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
Nathaniel_C
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

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

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

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

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