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
hmt1
Frequent Visitor

Measure Counting Rows Based Off Two Related Tables

Hi everyone, still kind of new to this. Normally I just have pretty striaght foward requests but this one has me using a secod table to validate I am count correctly. I am struggling with a measure to count locations where the what was sent matches what was requested. I have three tables and look like the following:

1) locations

2) what was shipped

3) what was requested

Table 1 Locations:

Location

Last Shipment

Location ID 1Shipment ID 1
Location ID 2Shipment ID 1
Location ID 3Shipment ID 2

 

Table 2 Shipment:

Shipment IDProduct
Shipment ID 1Item 1
Shipment ID 1Item 2
Shipment ID 2Item 5
Shipment ID 2Item 3

 

Table 3 Assigned:

LocationProduct
Location ID 1Item 1
Location ID 1Item 2
Location ID 2Item 1
Location ID 2Item 2
Location ID 3Item 4
Location ID 3Item 3

 

hmt1_1-1664290131573.png

 

I am trying to count by product items how many locations got the items they are assigned and how many were correctly shipped. The visual on the dashboard was expected to look something like this:

ProductLocations With ProductCorrect Locations With Product
Item 122
Item 222
Item 311
Item 400
Item 510

 

Location 3 got sent shipment 2 with products 3 and 5 but should have gotten 3 and 4. So item 4 is 0 for never being shipped and item 5 is counted as being at a location but show 0 as being correct locations. I am finding I can count locations with a product to get the first and second column but not sure how to get the count of correct locations. 

I have tried filltering where item shipped = item assigned and got errors on relationships of tables.

Found this one but not having any luck with it either.

 

COUNTROWS (
        SUMMARIZE ( FILTER ( location,
            location[id] IN VALUES ( assigned[location_id] )
            && assigned[item_id] = shipped[item_id]
            )
        , location[id] )
    )
 

Can I not count locations based on two related table matching?

 

Edit: Added relationship image

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @hmt1 

Sorry, I'm still confused about the results for items 4 and 5 for "Correct Locations With Product", can you explain more specifically?

 

Best Regards,
Community Support Team _ Eason

 

The goal is to show how many locations currently have the product on site in column 2 (count of locations with product) and also show how many of those products ended up at the correct locations in column 3. This is an audit type dashboard.

 

I can count the locations each product was shipped to and get the right numbers. When I then try to filter it down to correct locations I am stuck. Below the "Product" in the rows is coming from the shipment table. The values is just the number of locations in the related location table that got the shipment.

hmt1_0-1664290690783.png

 

 

If a product "Item" has to be at 5 locations but only 4 of them are correct locations we can only get paid for 4 locations. In the image above it you can see "Item 5" is at 1 location but looking at the assignment table it should never have been there so 0 correct locations should be counted in the second column.

hmt1_1-1664290942964.png

 

So it is known what the location has based on the last shipment via the shipment id and then it needs to be compared to the assignment table. If the product in the shipment last at a location matches what was assigned for that location it should be counted.

 

Thanks for any help you can give!

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.