Forum Discussion

PBIX1234's avatar
PBIX1234
Frequent Visitor
3 years ago

Measure with multiple dates & an exception

Hi, I am working with a model that has two fact tables joined by some shared dimensions.

 

The fact tables are our payments named SPEND (top left) and contract records named CONTRACTS (bottom right)

 

They are joined by Date & Supplier that are common, as well as Categories which has some mapping.

 

Screenshot of the model;

 

I am trying to create a measure for Contracted Spend. The conditions are;

Contracted Amount = 

Sum of SPEND(Amount)

 

Occurs after CONTRACTS(Start)

AND

Occurs before CONTRACTS(End) ... *UNLESS the CONTRACTS(Status) is "Active"

 

*The last condition is to account for contracts that are expired but rolling on terms - this is how our system tracks it.

 

I tried first getting the result excluding the exception of active contracts after expiry, but still didn't get the desired result;

 

Contracted Amount =
    CALCULATE(
                SUM(SPEND[AMOUNT]),
                CONTRACTS[START]<MAX('DATE'[Date]),
                CONTRACTS[END]>MAX('DATE'[Date]),
     )
 

How would this formula be phrased?

 
 
Many thanks!