I've got a measure where I'd like to have a USERELATIONSHIP clause in the CALCULATE. The code below works... however, I'm not clear why I can't add the USERELATIONSHIP as a filter parameter to the "inner" CALCULATE. If I do that without the outer CALCULATE the measure returns blank<blank>.
The AP Calendar table is a standard date table - the default relationship is to the Voucher Entered Date, but as I'm tracking discount payments I need to group my spend as of the payment date.
In order to receive a discount (e.g. 2% 10 days) we must pay prior to or on the discount due date.
The Payment Date is blank if vouchers have not been paid.
The Discount Date is blank if we do not offer a discount for that vendor.</blank>
Code:
Discount Taken Total :=CALCULATE (
CALCULATE (
SUM ( Vouchers[Discount Amount] ),
FILTER (
Vouchers,
NOT (
ISBLANK ( Vouchers[Discount Due Date] )
)
&& NOT (
ISBLANK ( Vouchers[Payment Date] )
)
&& Vouchers[Discount Due Date] >= Vouchers[Payment Date]
)
),
USERELATIONSHIP ( Vouchers[Payment Date], 'AP Calendar'[Date] )
)
In order to receive a discount (e.g. 2% 10 days) we must pay prior to or on the discount due date.
The Payment Date is blank if vouchers have not been paid.
The Discount Date is blank if we do not offer a discount for that vendor.</blank>