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.
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?
Ex.: se eu colocar no filtro o mês de julho, quantos clientes fizeram 1 compra, ou mais, entre os meses de Maio, Junho ou Julho?
Pode me ajudar, @v-yangliu-msft ?
Muito obrigado...
Solved! Go to Solution.
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 _flag
2. 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.
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 _flag
2. 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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
57 | |
49 | |
44 | |
18 | |
18 |