Forum Discussion
Calculate total previous year points earned based on decimal customer length and customer type?
- Anonymous2 years ago
Hi, alya1
Thanks for ryan_mayu's concern about this issue.
I am glad to help you.
According to your description, you can refer to my DAX formula New Column:
TotalPointsLastYear = VAR CustomerLength = [Length (yrs)] VAR CustomerType = [Customer Type] VAR PointsPerDay = SWITCH ( TRUE (), CustomerType = "A" && CustomerLength < 3, 5, CustomerType = "A" && CustomerLength >= 3, 10, CustomerType = "B" && CustomerLength < 3, 10, CustomerType = "B" && CustomerLength >= 3, 20, CustomerType = "C" && CustomerLength < 1, 10, CustomerType = "C" && CustomerLength >= 1 && CustomerLength < 5, 20, CustomerType = "C" && CustomerLength >= 5 && CustomerLength < 10, 30, CustomerType = "C" && CustomerLength >= 10, 40 ) VAR PreviousTierPoints = SWITCH ( TRUE (), CustomerType = "A" && CustomerLength < 3, 5, CustomerType = "A" && CustomerLength >= 3, 5, CustomerType = "B" && CustomerLength < 3, 10, CustomerType = "B" && CustomerLength >= 3, 10, CustomerType = "C" && CustomerLength < 1, 10, CustomerType = "C" && CustomerLength >= 1 && CustomerLength < 5, 20, CustomerType = "C" && CustomerLength >= 5 && CustomerLength < 10, 20, CustomerType = "C" && CustomerLength >= 10, 30 ) VAR FractionNewTier = CustomerLength - FLOOR ( CustomerLength, 1 ) VAR FractionOldTier = 1 - FractionNewTier RETURN ( FractionNewTier * 365 * PointsPerDay ) + ( FractionOldTier * 365 * PreviousTierPoints )
Here are my test results:I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, alya1
Thanks for ryan_mayu's concern about this issue.
I am glad to help you.
According to your description, you can refer to my DAX formula New Column:
TotalPointsLastYear =
VAR CustomerLength = [Length (yrs)]
VAR CustomerType = [Customer Type]
VAR PointsPerDay =
SWITCH (
TRUE (),
CustomerType = "A"
&& CustomerLength < 3, 5,
CustomerType = "A"
&& CustomerLength >= 3, 10,
CustomerType = "B"
&& CustomerLength < 3, 10,
CustomerType = "B"
&& CustomerLength >= 3, 20,
CustomerType = "C"
&& CustomerLength < 1, 10,
CustomerType = "C"
&& CustomerLength >= 1
&& CustomerLength < 5, 20,
CustomerType = "C"
&& CustomerLength >= 5
&& CustomerLength < 10, 30,
CustomerType = "C"
&& CustomerLength >= 10, 40
)
VAR PreviousTierPoints =
SWITCH (
TRUE (),
CustomerType = "A"
&& CustomerLength < 3, 5,
CustomerType = "A"
&& CustomerLength >= 3, 5,
CustomerType = "B"
&& CustomerLength < 3, 10,
CustomerType = "B"
&& CustomerLength >= 3, 10,
CustomerType = "C"
&& CustomerLength < 1, 10,
CustomerType = "C"
&& CustomerLength >= 1
&& CustomerLength < 5, 20,
CustomerType = "C"
&& CustomerLength >= 5
&& CustomerLength < 10, 20,
CustomerType = "C"
&& CustomerLength >= 10, 30
)
VAR FractionNewTier =
CustomerLength - FLOOR ( CustomerLength, 1 )
VAR FractionOldTier = 1 - FractionNewTier
RETURN
( FractionNewTier * 365 * PointsPerDay ) + ( FractionOldTier * 365 * PreviousTierPoints )
Here are my test results:
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
thank you fenling!!!