Forum Discussion
LuanRamos
5 years agoFrequent Visitor
Calcular clientes ativos
Olá, pessoal! Tenho uma base com os seguintes campos: Data de Venda; Cod_Cliente; Valor de Venda Como posso calcular quantos clientes realizaram 1 compra, ou mais, nos últimos três meses? ...
- Anonymous5 years ago
Hi LuanRamos,
Here are the steps you can follow:
1. Create a calculated column.
purchase= var _3monthbefore= CALCULATE( COUNT('Table'[Amount]), FILTER('Table', [Cod_Cliente]=EARLIER([Cod_Cliente]) && MONTH([Date])=MONTH(EARLIER([Date]))-3)) var _2monthbefore= CALCULATE( COUNT('Table'[Amount]), FILTER('Table', [Cod_Cliente]=EARLIER([Cod_Cliente]) && MONTH([Date])=MONTH(EARLIER([Date]))-2)) var _1monthbefore= CALCULATE( COUNT('Table'[Amount]), FILTER('Table', [Cod_Cliente]=EARLIER([Cod_Cliente]) && MONTH([Date])=MONTH(EARLIER([Date]))-1)) var _flag= SWITCH( TRUE(), _1monthbefore =1||_2monthbefore=1||_3monthbefore=1, "One time purchase", _1monthbefore >1||_2monthbefore>1||_3monthbefore>1,"Multiple purchases", "No purchase") return _flag2. Create measure
PURCHASE TIME = var _month=SELECTEDVALUE('Month'[Month]) RETURN IF( MONTH(MAX('Table'[Date]))>=_month-2&&MONTH(MAX('Table'[Date]))<=_month, 1,0)3. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
5 years agoNot applicable
Hi LuanRamos,
Here are the steps you can follow:
1. Create a calculated column.
purchase=
var _3monthbefore=
CALCULATE(
COUNT('Table'[Amount]),
FILTER('Table',
[Cod_Cliente]=EARLIER([Cod_Cliente])
&&
MONTH([Date])=MONTH(EARLIER([Date]))-3))
var _2monthbefore=
CALCULATE(
COUNT('Table'[Amount]),
FILTER('Table',
[Cod_Cliente]=EARLIER([Cod_Cliente])
&&
MONTH([Date])=MONTH(EARLIER([Date]))-2))
var _1monthbefore=
CALCULATE(
COUNT('Table'[Amount]),
FILTER('Table',
[Cod_Cliente]=EARLIER([Cod_Cliente])
&&
MONTH([Date])=MONTH(EARLIER([Date]))-1))
var _flag=
SWITCH(
TRUE(),
_1monthbefore =1||_2monthbefore=1||_3monthbefore=1, "One time purchase",
_1monthbefore >1||_2monthbefore>1||_3monthbefore>1,"Multiple purchases",
"No purchase")
return _flag2. Create measure
PURCHASE TIME =
var _month=SELECTEDVALUE('Month'[Month])
RETURN
IF(
MONTH(MAX('Table'[Date]))>=_month-2&&MONTH(MAX('Table'[Date]))<=_month,
1,0)3. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- LuanRamos5 years agoFrequent Visitor
Anonymous, tks.
You've help me a lot!