successken
New Member
- Joined
- Oct 3, 2011
- Messages
- 27
Here is an interesting one. I have been reworking my DAX to clean them up utilizing Variables. However, I have discovered (or not doing it correctly) that when I use a VAR in a Calculate that utilizes the USERELATIONSHIP DAX it ignores the DAX and defaults back to the active relationship.
Example-
$ of Gross Sales - Special =
VAR TypeFilter = FILTER( 'OrderItems' , 'OrderItems'[itemtype] = "S" )
VAR JobFilter = FILTER('Orders','Orders'[Type] = "Special" )
RETURN
CALCULATE( SUM( 'OrderItems'[Retail] ) , USERELATIONSHIP( 'OrderItems'[orderitemsdate] , 'Calendar'[Date] ) , TypeFilter , JobFilter )
vs.
CALCULATE( SUM( 'OrderItems'[Retail] ) , USERELATIONSHIP( 'OrderItems'[orderitemsdate] , 'Calendar'[Date] ) , 'OrderItems'[itemtype] = "S", 'Orders'[Type] = "Special")
The first returns incorrect vs the second that is correct. Am I doing something incorrect?
Example-
$ of Gross Sales - Special =
VAR TypeFilter = FILTER( 'OrderItems' , 'OrderItems'[itemtype] = "S" )
VAR JobFilter = FILTER('Orders','Orders'[Type] = "Special" )
RETURN
CALCULATE( SUM( 'OrderItems'[Retail] ) , USERELATIONSHIP( 'OrderItems'[orderitemsdate] , 'Calendar'[Date] ) , TypeFilter , JobFilter )
vs.
CALCULATE( SUM( 'OrderItems'[Retail] ) , USERELATIONSHIP( 'OrderItems'[orderitemsdate] , 'Calendar'[Date] ) , 'OrderItems'[itemtype] = "S", 'Orders'[Type] = "Special")
The first returns incorrect vs the second that is correct. Am I doing something incorrect?