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 values for a column while filtering another column

Hi Power BI Comunity, please help

I need to count values for column "Items_Category" in Power BI, if my source only gives me 2 columns- Category & Items?

Items_Category is the output in 3rd column/ measure derived by adding items based on Category, Eg: Electronics = 50+125+200 = 375, but it has to show for all Electronics related rows.

 

Should i add column or use measure- please suggest what, why and how- it would be great.

 

CategoryItemsItems_Category
Electronics50375
Clothing75450
Miscellaneous100525
Electronics125375
Clothing150450
Miscellaneous175525
Electronics200375
Clothing225450
Miscellaneous250525
1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hello @Gguliani ,

Try creating a column like the following:

CountCalc ? CALCULATE(SUM(tablename[Items]), FILTER(tablename, tablename[Category] ? EARLIER(tablename[Category] )))

Thank you

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

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

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

6 REPLIES 6
Pragati11
Super User
Super User

Hello @Gguliani ,

Try creating a column like the following:

CountCalc ? CALCULATE(SUM(tablename[Items]), FILTER(tablename, tablename[Category] ? EARLIER(tablename[Category] )))

Thank you

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

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

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Getting an error @Pragati11 , field names and table names are different than dummy values asked in the query

 

Gguliani_0-1596806824323.png

 

Hi @Anonymous ,

 

You forgot to close a bracket after SUM function in your DAX. Check my dax expression again.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

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

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

That's reckless from me. Thanks @Pragati11

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Your question is not very clear. Can you describe more on what's your current input is and what output is required?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

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

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Sorry, i realised that too and updated it, please check

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.