How to Create a Power BI Breach Measure by Matching Two Tables
Question details
The user needs to create a DAX measure in Power BI to identify a status breach by matching a Door table with a Store Status table using site identifiers and timestamps.

- Product
- Power BI
- Device & OS
- not provided
- Scenario
- Identifying status breaches by matching a Door table (Open status) with a Store Status table (Closed status) in a Power BI data model.
- Observed behavior
- The goal is to align the timestamps of both tables and output a '1' when the specific breach condition is met, while calculating accurate grand totals.
Ensure that both your Door table and Store Status table share a common site identifier column and that their timestamp columns can be normalized to match exactly.
Round Timestamps and Create a DAX Measure
Standardize timestamps in Power Query to allow precise matching between tables, then use a DAX measure to evaluate the breach condition.
When comparing two tables in Power BI, exact matches are required for relationships and specific DAX lookups. If the timestamps are not aligned, rounding them in Power Query is necessary before writing the DAX formula.
Open the Power Query Editor, locate the 'CreatedOn' column in your Door table, and apply a transformation to round the datetime values to the nearest half-hour so they align with the Store Status table.
In Power BI Desktop, create a new measure that uses DAX variables to check for the combined status. Use the formula: _Breach = VAR Statuses = MAX(Door[Status]) & [_Status] VAR Breach = IF(ISBLANK([_Status]),BLANK(),IF(Statuses="OpenC",1,0)) RETURN IF(HASONEVALUE(Door[SiteId]),Breach,BLANK()).
Because the core measure relies on HASONEVALUE to evaluate row contexts, standard totals will appear blank. Create a secondary measure using SUMX to calculate the total: Total Breaches = SUMX(Door, [_Breach]).

Analyze Your Data Efficiently with WPS Office
While Power BI is the go-to tool for complex DAX modeling, you can perform extensive daily data analysis, pivot tables, and status matching using WPS Spreadsheet—a free, lightweight alternative to Microsoft Office. Enjoy a familiar interface and seamless compatibility with Excel formats.
- 1. Install WPS Office: Download and install the free WPS Office suite from the official website to your device.
- 2. Import Your Data: Open WPS Spreadsheet and easily import your raw data or exported CSV files.
- 3. Match and Analyze: Use built-in lookup functions and conditional formatting to quickly identify status breaches without writing complex code.

Frequently Asked Questions
Why does my DAX measure return blank instead of zero?
The measure is designed to return BLANK() when there is no matching Store Status record or when the row does not have a single specific SiteId. This ensures that only valid, matched rows are evaluated in your visuals.
How do I align timestamps if they differ by a few minutes?
You can use Power Query to round your datetime columns. By transforming the 'CreatedOn' column to round to the nearest 30-minute interval, you force the timestamps to align with the matching table.
Why do I need to use SUMX for the total breaches?
Because the primary breach measure uses 'HASONEVALUE' to evaluate specific row contexts, a standard SUM function cannot evaluate it correctly at the Grand Total level. SUMX iterates over the table row by row to correctly aggregate the final result.
Can I match the tables directly without DAX?
If both tables have a perfectly matched SiteId and rounded DateTime column, you can establish a one-to-one or many-to-one relationship in the Power BI Model view, allowing you to build simple visuals without complex DAX.




