Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
alya1
Helper V
Helper V

Calculate total previous year points earned based on decimal customer length and customer type?

Hello All,

 

I have a table like below

ID   Customer Length (yrs)   Customer Type   Benefit points per day (calculated column based on customer length and type)   
1113.1A10
2228B20
3335.2C30


The benefit points per day is calculated using below logic
Customer type A, less than 3 yrs = 5, 3+ yrs = 10
Customer type B, less than 3 yrs = 10, 3+ yrs = 20
Customer type C, less than 1 yr = 10, 1-5 yrs = 20, 5-10 yrs = 30, 10+ yrs = 40

I only have data as of today. 
Is it possible to calculate the total points earned per customer throughout the entire last year (total 365 days) using the information I have above in PowerBI? 
The current rate * 365 would not be accurate as that some customers just pushed past a new benefit points tier like 111 and 333.
See below for goal results column and reasoning: 

IDCalcResultsNotes
111  0.1*365*10+0.9*365*52007.5  Since 111 is at 3.1 yrs, only 0.1 of the year is at 10 pts/day and 0.9 is at the previous tier of 5 pts/day
22220*3657300Since 222 is at 8 yrs and more than 1 yr from cut off of 3 yrs, it's just * 365
3330.2*365*30+0.8*365*20  8030Since 333 is at 5.2 yrs, only 0.2 of the year is at 30 pts/day and 0.8 is at the previous tier of 20 pts/day



Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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:

vfenlingmsft_0-1725601985204.png

 

 

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.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

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:

vfenlingmsft_0-1725601985204.png

 

 

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!!!

ryan_mayu
Super User
Super User

@alya1 

could you pls provide the expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Ryan,
Yes please see below Results column! I added calc and notes for background thank you!

ID   Calc                               Results  Notes    
1110.1*365*10+0.9*365*5   2007.5Since 111 is at 3.1 yrs, only 0.1 of the year is at 10 pts/day and 0.9 is at the previous tier of 5 pts/day
22220*3657300Since 222 is at 8 yrs and more than 1 yr from cut off of 3 yrs, it's just * 365
3330.2*365*30+0.8*365*20  8030Since 333 is at 5.2 yrs, only 0.2 of the year is at 30 pts/day and 0.8 is at the previous tier of 20 pts/day

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.