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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PaulDBrown
Community Champion
Community Champion

Client Status Report: "Repating", "New" or "Lost" clients relative to another period

Good Afternoon from "sunny" Spain...!

 

I was hoping someone could point me in the appropriate directio to understand how to generate a report, based on a sales table including (Client Name, Date of purchase, ...) which will allow for the addition of billings according to their status ("Repeating", "Lost" or "new client") when comparing their purchases between to periods.

 

The idea of what I'm trying to achieve is as follows (Excel Example):

Client Status YoY.PNG

 

(I guess I haven't completely succeeded in getting my brain out of Excel mode...)

It's not the structure of the report I'm actually after, but rather how do I go about classifying the clients base on whether they are repeating, new or lost customers when comparing two periods.

 

Is there an example or tutorial available to anyone's knowledge?

 

Thank you so much for your help.

 

Best regards,

Paul.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






1 ACCEPTED SOLUTION

@dedelman_clng @nairisha

David,

 

Thank you, I did try with the corrected YEAR. What I'm seeing is a single value of "REPEAT" along all lines (this is not surprising when I try the whole current year as per your formula, since my data set only has repeating clients this current year; I'm going to have to change some rows manually to force the data to deliver different outputs and see if it works.

 

However there are "New" and "Lost" clients month by month, and I've tried using the formula including:

YEAR(Tab[Date])=Year(TODAY()) && MONTH(Tab[Date] = MONTH(TODAY())

YEAR(Tab[Date])=Year(TODAY())-1 && MONTH(Tab[Date] = MONTH(TODAY())

 

for the current month but it also delivers "Repeat" as a unique value across all rows, when there are other types of clients in the current month. So I'm going to have to work deep to find out what is going on.

 

BUT there is a bright side to all of this! I subsequently found a workaround (I'm kicking myself for not having thought of this before).... In the report I'm working on for this model, it occured to me to filter the visual displaying columns for [client], [this year sales], [last year sales] and [% difference between both years].

So basically what I've done is (using the Visual Filters and filtering by the % difference column which is a measure using the DIVIDE function):

 

REPEAT;  when % DIFF IS NOT BLANK AND IS NOT -100% (-100% is the value computed when there is a sales value in last year and no result this year)

NEW: when the % DIFF IS BLANK (BLANK is computed when the denominator is 0 within the DIVIDE function)

LOST: when the % DIFF = -100%

 

and there you go!!

 

Not ideal, since it means I have to repeat the process every time I want to do any kind of analyses based on client status, but at least I've got it working!

 

Thank you again for all your help!!

 

Best regards,

 

Paul.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

24 REPLIES 24

@dedelman_clng David, WOW!

 

That was very helpful, though I feel I'm out of my league in this exercise...

 

As regards the this year/last year functionality, I don't suppose adding an expression along the lines of "tab[year]=YEAR(TODAY())" would work?

 

Another concern I'm having is if this calculated column in the context of thousands, if not millions of rows would be a hog and severly affect response times.

 

Many thanks again for you generous help!

 

Paul.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown I have to credit @Vvelarde for the code inspiration as an answer to a different post.  I still need to look back through my reference books and understand why it's working instead of just being happy that it does work Smiley Happy

 

Also *headslap* to me for no thinking of something simple like YEAR(TODAY()).  I was focused on using the YEAR value in the data itself and that was causing weird results. Also note that data outside of the two year window will cause things to show blank.

 

If at all possible, you would want to bring as much raw data in PowerBI as possible in order to take full advantage of all of the time intelligence functions that DAX offers.

 

Glad I could help,

David

dedelman_clng
Community Champion
Community Champion

You should be able to do this with measures and IF statements

 

TotSales = calculate(
     sum(table[sales])
)

LYTotSales = calculate (
     sum(table[sales]),
     SAMEPERIODLASYEAR(table[Date of Purchase])

CustomerType = 
IF (AND(TotSales = 0, LYTotSales <> 0), "LOST",
    IF(AND(TotSales <> 0, LYTotSales <> 0), "REPEAT",
       IF(AND(TotSales <> 0, LYTotSales = 0), "NEW", BLANK()
       )
     )
)

Hope this helps

 

David

Thank you dedelman_clng,

 

That was really helpful. Sorry is this next question seems basic, but does the "IF Satement" go in a CALCULATED COLUMN in the sales table or is it a separate MEASURE?

 

Paul.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.