Reputation: 13
Tried to add new measures via PowerBI but the EARLIER functions seem not working properly.
The dataset including Year, Month, DealerName, MerchantType, Province, TotalApplications, and Requested Amount. I want to calculate the Total Applications based on DealerName and MerchantType respectively. Please see one of the functions below:
Merchant_TotalApp = CALCULATE(SUM('Requested Summary'[TotalApplications]), FILTER('Requested Summary','Requested Summary'[MerchantType] = EARLIER ('Requested Summary'[MerchantType]))))
The EARLIER ('Requested Summary'[MerchantType]) is underlined red and the error message is "EARLIER/EARLIEST refers to an earlier row context which doesn't exist". When hovering over to the error part, it showing "parameter is not the correct type".
Wondering how to solve the problem? is it related to the data type erro or anything. Thanks for any help!
Upvotes: 1
Views: 5557
Reputation: 3665
EARLIER is rarely used in Measures.
It is used in an iterator function when you want to compare what's in the current row context to a prior row context.
In your current Measure, the FILTER function is not nested within a row context, so the EARLIER function has nothing to 'look back' to.
If what you are after are sums that pay attention only to Merchant type and ignore any other filters - you can get that with on of the ALL functions.
Merchant_TotalApp =
CALCULATE (
SUM ( 'Requested Summary'[TotalApplications] ),
ALLEXCEPT('Requested Summary','Requested Summary'[MerchantType])
)
Upvotes: 1