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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculate how many based on 2 tables.

Hi.

 

A rookie question I hope someone can help me with.


I have 2 tables. 1 tables with categories and another table with same categories, but also with a number.

 

So, what I want to do is calculate how many of the categories in table 1 based on the number with same category in table 2.
Please look at my attach example of tables at the bottom.

 

As you can see in my example tables at the bottom I have Apples 3 times in table 1, and in table 2 an apple have the number 2. Then I need to multiply 3x2=6. Bananas is also 3 times, but the number there is 4, so then I need to multiply 3x4.
This I want to do with a measure and then summarize it all up in one KPI vizual.


Anyone who can help me with this?


Best regards
Mariusexample.png

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

you can use DAX statement to create a measure in Table 2

Measure = 
SUMX(
	'Table2'
	,var currentCategory = 'Table2'[Category]
	return
	'Table2'[Amount] *
	COUNTROWS(
		FILTER('Table1'
			,'Table1'[Category] = currentCategory
		)
	)
)

Hope this is what you are looking for

 

Regards and have a nice weekend

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

From Table2, drag Ctegory to the visual.  Enter this calculated field formula

 

=SUMX(Table2,Table2[Number]*COUNTROWS(Table1))

Hope thish helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
TomMartens
Super User
Super User

Hey,

 

you can use DAX statement to create a measure in Table 2

Measure = 
SUMX(
	'Table2'
	,var currentCategory = 'Table2'[Category]
	return
	'Table2'[Amount] *
	COUNTROWS(
		FILTER('Table1'
			,'Table1'[Category] = currentCategory
		)
	)
)

Hope this is what you are looking for

 

Regards and have a nice weekend

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Superb, exactly what I needed! Thank you so much.

 

Best regards

Marius

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors