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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count against to other column

Hi All,

 

New to Power BI, i have data Category and Number.

 

I need the count as below, how can i write dax function. Please help me.

 

CategoryNumber

Count

AAA112
BBB112
CCC224
DDD224
EEE224
FFF224
GGG333
HHH333
III333
JJJ441

 

Thanks.

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

I would create a measure using the following (Replace Table1 with your table name):

Count of Category = 
    CALCULATE (
        COUNTROWS ( Table1 ),
        REMOVEFILTERS ( Table1[Category] )
    )

 

You can then drop the two columns and the measure into a table visual:

 

bcdobbs_0-1644352846994.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Number", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Number"}, {{"GroupTables", each _, type table [Category=nullable text, Number=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "CountRows", each Table.RowCount([GroupTables])),
    #"Expanded GroupTables" = Table.ExpandTableColumn(#"Added Custom", "GroupTables", {"Category"}, {"Category"})
in
    #"Expanded GroupTables"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
bcdobbs
Community Champion
Community Champion

I would create a measure using the following (Replace Table1 with your table name):

Count of Category = 
    CALCULATE (
        COUNTROWS ( Table1 ),
        REMOVEFILTERS ( Table1[Category] )
    )

 

You can then drop the two columns and the measure into a table visual:

 

bcdobbs_0-1644352846994.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Anonymous
Not applicable

Thanks for your quick reply. I have created the measusre 

 

Count FMS1 =
CALCULATE( COUNTROWS ( Query1), REMOVEFILTERS (Query1[FMS_REPORTING_CATEGORY]))
 
 
swamymba0905_0-1644353316855.png

 

It is showing as 1. but i need 4 instead of 1.

 
 

What other columns are in your visual?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.