Forum Discussion
jludwick
2 years agoFrequent Visitor
Change DAX calculated column using EARLIER Function
Hello, I recently read that you should not use the EARLIER function. I recently inherited a dataset file that uses this function and it keeps crashing, likely due to the EARLIER function. I am tr...
- Anonymous2 years ago
Hi jludwick ,
If you want to create a calculated column, you can try:
_Balance Cumulative = var _a=Invoices[Invoice Date] return calculate(sum(Invoices[Balance]), ALLEXCEPT(Invoices,Invoices[Customer ID + Company Desc]), filter( all(Invoices[Invoice Date]),Invoices[Invoice Date] <= _a ))If you want to create a measure, you can try:
_Balance Cumulative = calculate(sum(Invoices[Balance]), ALLEXCEPT(Invoices,Invoices[Customer ID + Company Desc]), filter( all(Invoices[Invoice Date]),Invoices[Invoice Date] <= MAX(Invoices[Invoice Date])))Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ThxAlot
2 years agoSuper User
In a calculated column, it's highly recommended to use VAR to subsitute for EALIER/ERLIEST for better readability and maintainability,
_Balance Cumulative =
VAR __dt = Invoices[Invoice Date]
RETURN
CALCULATE(
SUM( Invoices[Balance] ),
ALLEXCEPT( Invoices, Invoices[Customer ID + Company Desc] ),
Invoices[Invoice Date] <= __dt
)