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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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