Skip to content

Fix reversed USERELATIONSHIP argument detection - #382

Open
ArturNawrocki wants to merge 2 commits into
microsoft:masterfrom
ArturNawrocki:patch-1
Open

Fix reversed USERELATIONSHIP argument detection#382
ArturNawrocki wants to merge 2 commits into
microsoft:masterfrom
ArturNawrocki:patch-1

Conversation

@ArturNawrocki

Copy link
Copy Markdown

Summary

Fixes a false positive in the
INACTIVE_RELATIONSHIPS_THAT_ARE_NEVER_ACTIVATED rule.

The existing regular expression assumes that USERELATIONSHIP arguments
follow the internal TOM From-to-To order. DAX permits the arguments in
either order and swaps reversed arguments automatically.

This change:

  • Checks both argument orders in measures and calculation items.
  • Uses RegEx.Escape for complete DAX column references, preventing table
    names containing regex metacharacters, such as parentheses, from causing
    false positives.

Fixes a false positive in the `INACTIVE_RELATIONSHIPS_THAT_ARE_NEVER_ACTIVATED` rule.

The current expression detects `USERELATIONSHIP` only when its arguments
follow the TOM `From` to `To` relationship order. DAX permits the two
relationship columns to be supplied in either order.

## Changes

- Check both valid `USERELATIONSHIP` argument orders.
- Apply the check to measures and calculation items.
- Preserve the existing rule ID, severity and scope.

## Validation

Tested with:

- `From` to `To` arguments in a measure
- reversed arguments in a measure
- `From` to `To` arguments in a calculation item
- reversed arguments in a calculation item
- an unused inactive relationship

The unused relationship remains a violation. All four valid
`USERELATIONSHIP` cases are recognised.

## Reference

https://learn.microsoft.com/en-us/dax/userelationship-function-dax
Small fix to INACTIVE_RELATIONSHIPS_THAT_ARE_NEVER_ACTIVATED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant