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.
Hi experts,
I'd like to count rebills only when they occur after 24 hours of previous purchase.
I have data of this format:
DateTime | Month | Transaction ID | Item Code | Cash Amount | Sales Amount | Customer ID
[Month] is simply a calculated column: Month([DateTime])
I also have a Pivot Table with [Item Code] and [Month] on the row as I would like to check rebill rate of each merchandise for each month. I'm OK with the small flaw such that a purchase occurs at the first day of a month may be classified as a rebill while the last purchase occurred less than 24 hours ago.
My thought:
Since I want to ignore any [Transaction ID] made by the same [Customer ID] within 24 hours of this row (Using COUNTX() to add a row context), something similar to the following should work, in pseudo code:
Measure :=CALCULATE(COUNTX(Sales, Sales[Customer ID]), FILTER(Sales, Sales[DateTime] > Sales[DateTime] of this row plus 24 hours))
However because I cannot use EARLIER() to fetch Sales[DateTime] of this row, I'm kind of loss here. Would appreciate any help, and especially if you can share a general way to reference the current row in a measure.
Hi,
Share the link from where i can download your PBI file.
Hi,
Write this calculated column formula in Table1
=if(ISBLANK(CALCULATE(max(Table1[Time]),FILTER(Table1,Table1[Customer ID]=EARLIER(Table1[Customer ID])&&Table1[Time]<EARLIER(Table1[Time])))),BLANK(),[Time]-CALCULATE(max(Table1[Time]),FILTER(Table1,Table1[Customer ID]=EARLIER(Table1[Customer ID])&&Table1[Time]<EARLIER(Table1[Time]))))
This column will give you "Time elapsed since previous purchase". Now you should be able to write a measure with the condition that the time stamp in this colum should be <=TIME(24,0,0)
Hope this helps.
Thanks! Just curious, is there a way to do this in a measure without ADDCOLUMN()?
Hi,
I am not using the ADDCOLUMN() function. I am using a calculated column formula.
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 |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |