Forum Discussion
Calculate value based on unique values in different table
Assuming I have not misspelled your table or column names, all you need is two measures (not calcualated columns) for you Location table and two measures for you Inspection table which you will find below.
In a matrix, put [InspectionID] in the Rows field well, and put both [Location Count by Inspection ID] and [Equipment Count By Inspection ID] in the Values field well .
The other two measures are for intermediate calculations and are not to be put in the matrix.
I tried to use your sample data and it was hard to tell if the formulas were working. I created a similar model with fewer row and testing showed the formulas worked.
Equipment Count=COUNTROWS ( FILTER ( Location, Location[Item type] = "Equipment" ) )
Location Count=COUNTROWS ( FILTER ( Location, Location[Item Type] = "Location" ) )
Location Count for Inspection ID=CALCULATE ( [Location Count], CROSSFILTER ( Data[LocationID], Location[LocationID], Both ) )
Equipment Count By Inspection ID=CALCULATE ( [Equipment Count], CROSSFILTER ( Data[LocationID], Location[LocationID], Both ) )