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á,
Estou tentando criar um código para calcular a semana que os clientes compraram.
Usei o DAX:
Solved! Go to Solution.
@Daniela_Romasko Try like
Purchase Frequency = Countrows(Summarize(TB_FATURAAMENTO, TB_FATURAAMENTO[Year Week], TB_FATURAAMENTO [N NOTE] ) )
Hi @Daniela_Romasko ,
I created some data:
Here are the steps you can follow:
1. In Power Query -- Add Column – Index Column – From 1.
2. Create calculated column.
Count =
COUNTX(
FILTER(ALL('Table'),
'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Week]=EARLIER('Table'[Week])),[Week number])
Flag =
var _min=
MINX(FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Week]=EARLIER('Table'[Week])),[Index])
return
IF(
_min=[Index],1,0)
increase+1 =
[Count] +
SUMX(FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Index]<=EARLIER('Table'[Index])),[Flag])
Week number =
CALCULATE(DISTINCTCOUNT('Table'[Week]),
FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])))
3. Result:
If it doesn't meet your expectations,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you
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 @Daniela_Romasko ,
I created some data:
Here are the steps you can follow:
1. In Power Query -- Add Column – Index Column – From 1.
2. Create calculated column.
Count =
COUNTX(
FILTER(ALL('Table'),
'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Week]=EARLIER('Table'[Week])),[Week number])
Flag =
var _min=
MINX(FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Week]=EARLIER('Table'[Week])),[Index])
return
IF(
_min=[Index],1,0)
increase+1 =
[Count] +
SUMX(FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Index]<=EARLIER('Table'[Index])),[Flag])
Week number =
CALCULATE(DISTINCTCOUNT('Table'[Week]),
FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])))
3. Result:
If it doesn't meet your expectations,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you
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
@Daniela_Romasko Try like
Purchase Frequency = Countrows(Summarize(TB_FATURAAMENTO, TB_FATURAAMENTO[Year Week], TB_FATURAAMENTO [N NOTE] ) )
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 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |