Forum Discussion
Calculated Column Assistance "Customer Contract State"
- 6 years ago
H Smoody
Pleaase consider ths solution and leave kudosHere are some DAX measure you can tweak ....
AllContractsForCustomer =
/*
This measure counts all contracts for a customer.
The ALL removes all the filters including the row context filter, then VALUES reapplies the customer context
*/
CALCULATE (
COUNTROWS(Contracts),
All (Contracts),
VALUES(Contracts[Customer])
)
ActiveContractsForCustomer =/*
This measure counts all active contracts for the customer.
The ALL removes all the filters including the row context filter, then VALUES reapplies the customer context.
Then is just filters ACTIVE
*/
CALCULATE (
COUNTROWS(Contracts),
All (Contracts),
VALUES(Contracts[Customer]),
Contracts[Contract status]="ACTIVE"
)InactiveContractsForCustomer =
/*
This measure counts all inactive contracts for the customer.
The ALL removes all the filters including the row context filter, then VALUES reapplies the customer context.
Then is just filters INACTIVE
*/
CALCULATE (
COUNTROWS(Contracts),
All (Contracts),
VALUES(Contracts[Customer]),
Contracts[Contract status]="INACTIVE"
)I assume you just needed help overriding the row context. and you can do the rest from now on, because you seem to have a good grasp of IF logic.
- 6 years ago
Anonymous add two calculated columns
Lost Y-N = VAR __countActive = CALCULATE ( COUNTROWS ( Table ), ALLEXCEPT ( Table, Table[Customer] ), Table[Contract State] = "Active" ) RETURN IF ( __countActive >= 1, "Active", "Inactive" )Most Recent Expiration Date = IF ( Table[Lost Y-N] = "Inactive", CALCULATE ( MAX ( Table[Expiration Date]), ALLEXCEPT ( Table, Table[Customer] ) )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
H Smoody
Pleaase consider ths solution and leave kudos
Here are some DAX measure you can tweak ....
AllContractsForCustomer =
/*
This measure counts all contracts for a customer.
The ALL removes all the filters including the row context filter, then VALUES reapplies the customer context
*/
CALCULATE (
COUNTROWS(Contracts),
All (Contracts),
VALUES(Contracts[Customer])
)
ActiveContractsForCustomer =
/*
This measure counts all active contracts for the customer.
The ALL removes all the filters including the row context filter, then VALUES reapplies the customer context.
Then is just filters ACTIVE
*/
CALCULATE (
COUNTROWS(Contracts),
All (Contracts),
VALUES(Contracts[Customer]),
Contracts[Contract status]="ACTIVE"
)
InactiveContractsForCustomer =
/*
This measure counts all inactive contracts for the customer.
The ALL removes all the filters including the row context filter, then VALUES reapplies the customer context.
Then is just filters INACTIVE
*/
CALCULATE (
COUNTROWS(Contracts),
All (Contracts),
VALUES(Contracts[Customer]),
Contracts[Contract status]="INACTIVE"
)
I assume you just needed help overriding the row context. and you can do the rest from now on, because you seem to have a good grasp of IF logic.
- Anonymous6 years agoNot applicable
Thanks a ton! You hit the nail on the head for the issue. I completely forgot to get the except statement in there.