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

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
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.