Forum Discussion
APR92
2 years agoFrequent Visitor
Detect Past Month lost customer
Hi, I'm trying to find the customers that I lost from the previous month. So far I've been able to calculate it individually but I'm stuck with the subtotals. The model is a single table inndic...
- 2 years ago
Hey APR92, there is probably a much cleaner way to do this, but try this:
Lost2 = VAR selectedDate = SELECTEDVALUE(Consulta1[Date]) VAR selectedCategory = SELECTEDVALUE(Consulta1[Category]) VAR tbl = ADDCOLUMNS ( ADDCOLUMNS ( Consulta1, "Active Last Month", MAXX ( FILTER ( ALL ( Consulta1 ), Consulta1[Date] < EARLIER(Consulta1[Date]) && ( Consulta1[Category] = EARLIER(Consulta1[Category]) || ISBLANK ( EARLIER(Consulta1[Category]) ) ) ), Consulta1[Active] ) ), "Lost", SWITCH ( TRUE, ISBLANK ( [Active Last Month] ), BLANK (), [Active Last Month] < Consulta1[Active], 0, [Active Last Month] - Consulta1[Active] ) ) VAR lost = SUMX ( FILTER ( tbl, Consulta1[Date] = selectedDate && ( Consulta1[Category] = selectedCategory || ISBLANK ( selectedCategory ) ) ), [Lost] ) RETURN lost
giammariam
Solution Sage
2 years agoAPR92, this is because of the desired behavior was unclear. Overall for 2023-03 you had 4 currently active where you only had 3 active the month before. Since you still ended up with a total of more active than you did the previous month, the [Lost] metric is indicating that overall you didn't lose any for that month. Sounds like instead you want a total of any lost, regardless of what the overall picture is for that month. Now that I know that this is the desired behavior I'll try to get this implemented as soon as I get a chance.