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
ElvirBotic
Helper III
Helper III

Count Inspections for each Location Once and only Once

I have a dataset where I need to count completed Inspections for each location and count it only once. I will create a table of mock data I am working with. The users will inspect different locations. Each quarter a location needs to complete 1 Long inspection and 2 short inspections. There are Instances where users will complete a long inspection twice in a quarter and we do not want it to count more than once. Same goes for short inspections. If the user completes more than 2 short inspections we only want to count two for each location. I hope that clarifys things. If I can answer anymore questions I would be glad to. 

Data:

SiteIDDate CompletedInspection Type
101/15/2022Long
101/16/2022Long
202/11/2022Short
304/04/2022Short
103/11/2022Short
202/06/2022Short
102/15/2022Long
203/04/2022Short

 

Result:

SiteTypeTotalQuarter
1Long11
1Short01
2Long01
2Short21
3Long01
3Short12
4 REPLIES 4
johnt75
Super User
Super User

Try

Total inspections =
var numInspections = CALCULATE( COUNTROWS('Data') )
var inspectionType = SELECTEDVALUE('Data'[Inspection type])
var result = IF( inspectionType = "Long", IF( numInspections > 1, 1, numInspections),
IF( numInspections > 2, 2, numInspections) )
return result

I tried your approach and when I add the measure to a matrix visual my totals row is 1, which is not correct. 

Rename the original measure to Individual Inspections and then create a new measure as

Total Inspections = IF( ISINSCOPE( 'Data'[Site]), [Individual Inspections],
SUMX( ADDCOLUMNS( SUMMARIZE( 'Data', 'Data'[Site], 'Data'[Type]), 
"@value", CALCULATE( [Individual Inspections] ), [@value] )
)

I had no luck with this 😞

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.

Users online (9,952)