Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreShape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.
Hi,
I would like to average day that customer repurchase by each product and average day that each customer buy again . sorry for inconvenience becasue I got the error, when i post the data with table.
1. For example, average day that customer repurchase by each product
From the data, Average Day repurchase by product become as table below
First product, customer A bought on 29 Oct and 3 Nov so result of average day repurchase should be 5
Second product, costumer B bought on 29 Oct and 3 Nov(Day diff. = 5), customer c bought on 29 Oct and 2 Nov(Day diff. = 2), customer B also bought on 5 Nov (Day diff= 2 from the last day(3 Nov ) by the same product and the same customer purchase ).The result of average day repurchase should be(5+2+2)/3=3 day
However, costumer C bought packages 3 and costumer A bought packages 2 on 4 Nov.This is first time of buying so not should be counted.
2. For example, average day that customer repurchase by each customer
As the same data, average day repurchase by each customer become as table below
For customerA, he brought on 29 Oct,3 Nov and 4 Nov. It has 2 period. Date diif are 5 and 1 so result of average day repurchase by each customer should be 3 days.
For customerB, he bought on 29 Oct, 3 Nov( 2 times ), 4 Nov, 5 Nov and 12 Nov. It has 5 period. Date diif are 5 ,0,1,1 and 7 so result of average day repurchase by each customer should be 5.8 days.
For customerC, he bought on 29 Oct, 2 Nov and 4 Nov. It has 2 period. Date diif are 4 and 2 so result of average day repurchase by each customer should be 3 days.
Pls, Help me to figure out how can I do this in measure? If you also have any suggestion, let's me know.
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
Average day repurchase by package: =
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, Data[Customer Name], Data[Date] ),
"@currentrowdate", CALCULATE ( MAX ( Data[Date] ) ),
"@prevrowdate",
MAXX (
FILTER (
Data,
Data[Date] < EARLIER ( Data[Date] )
&& Data[Customer Name] = EARLIER ( Data[Customer Name] )
),
Data[Date]
)
),
[@prevrowdate] <> BLANK ()
)
VAR _diff =
ADDCOLUMNS ( _t, "@diff", [@currentrowdate] - [@prevrowdate] )
RETURN
DIVIDE ( SUMX ( _diff, [@diff] ), SUMX ( _diff, 1 ) )
Average day repurchase by customer: =
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, Data[Packages Purchase], Data[Date] ),
"@currentrowdate", CALCULATE ( MAX ( Data[Date] ) ),
"@prevrowdate", MAXX ( FILTER ( Data, Data[Date] < EARLIER ( Data[Date] ) ), Data[Date] )
),
[@prevrowdate] <> BLANK ()
)
VAR _diff =
ADDCOLUMNS (
SUMMARIZE ( _t, [@currentrowdate], [@prevrowdate] ),
"@diff", [@currentrowdate] - [@prevrowdate]
)
RETURN
DIVIDE ( SUMX ( _diff, [@diff] ), SUMX ( _t, 1 ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Thanks for answering, I appreciate you. That helps a lot.
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
Average day repurchase by package: =
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, Data[Customer Name], Data[Date] ),
"@currentrowdate", CALCULATE ( MAX ( Data[Date] ) ),
"@prevrowdate",
MAXX (
FILTER (
Data,
Data[Date] < EARLIER ( Data[Date] )
&& Data[Customer Name] = EARLIER ( Data[Customer Name] )
),
Data[Date]
)
),
[@prevrowdate] <> BLANK ()
)
VAR _diff =
ADDCOLUMNS ( _t, "@diff", [@currentrowdate] - [@prevrowdate] )
RETURN
DIVIDE ( SUMX ( _diff, [@diff] ), SUMX ( _diff, 1 ) )
Average day repurchase by customer: =
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, Data[Packages Purchase], Data[Date] ),
"@currentrowdate", CALCULATE ( MAX ( Data[Date] ) ),
"@prevrowdate", MAXX ( FILTER ( Data, Data[Date] < EARLIER ( Data[Date] ) ), Data[Date] )
),
[@prevrowdate] <> BLANK ()
)
VAR _diff =
ADDCOLUMNS (
SUMMARIZE ( _t, [@currentrowdate], [@prevrowdate] ),
"@diff", [@currentrowdate] - [@prevrowdate]
)
RETURN
DIVIDE ( SUMX ( _diff, [@diff] ), SUMX ( _t, 1 ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
The result is perffect. Thank you for your time.
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
21 | |
21 | |
13 | |
12 |
User | Count |
---|---|
43 | |
28 | |
25 | |
23 | |
22 |