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,
I'm trying to make a calculated column that can distinguish between first/re purchase of each item per each customer.
I need the last column!
Please help!!
Thanks so much!!
CUSTOMERITEMPURCHASE DATEQTYCOLUMN
CUSTOMER A | ITEM A | 1/1/2018 | 1 | FIRST PURCHASE |
CUSTOMER A | ITEM A | 1/2/2018 | 2 | RE PURCHASE |
CUSTOMER A | ITEM A | 1/3/2018 | 3 | RE PURCHASE |
CUSTOMER A | ITEM A | 1/4/2018 | 4 | RE PURCHASE |
CUSTOMER A | ITEM B | 1/5/2018 | 5 | FIRST PURCHASE |
CUSTOMER A | ITEM B | 1/6/2018 | 6 | RE PURCHASE |
CUSTOMER A | ITEM B | 1/7/2018 | 7 | RE PURCHASE |
CUSTOMER A | ITEM B | 1/8/2018 | 8 | RE PURCHASE |
CUSTOMER A | ITEM B | 1/9/2018 | 9 | RE PURCHASE |
CUSTOMER B | ITEM A | 1/10/2018 | 10 | FIRST PURCHASE |
CUSTOMER B | ITEM A | 1/11/2018 | 11 | RE PURCHASE |
CUSTOMER B | ITEM A | 1/12/2018 | 12 | RE PURCHASE |
CUSTOMER B | ITEM A | 1/13/2018 | 13 | RE PURCHASE |
CUSTOMER B | ITEM B | 1/14/2018 | 14 | FIRST PURCHASE |
CUSTOMER B | ITEM B | 1/15/2018 | 15 | RE PURCHASE |
CUSTOMER B | ITEM B | 1/16/2018 | 16 | RE PURCHASE |
CUSTOMER B | ITEM B | 1/17/2018 | 17 | RE PURCHASE |
CUSTOMER B | ITEM B | 1/18/2018 | 18 | RE PURCHASE |
Solved! Go to Solution.
Hey,
I guess this DAX statement used with a calculated column creates what you are looking for:
result = var currentCustomer = 'Table1'[Customer] var currentItem = 'Table1'[Item] var minDate = CALCULATE( MIN('Table1'[Purchase Date]) ,ALL(Table1) ,'Table1'[Customer] = currentCustomer ,'Table1'[Item] = currentItem ) return IF( AND( AND('Table1'[Customer] = currentCustomer, 'Table1'[Item] = currentItem) ,'Table1'[Purchase Date] = minDate ) ,"First Purchase" ,"Re Purchase" )
At least the new column "result" contains the same values of the column COLUMN from the sample data you provided, please note that I renamed the column from the test data to "TestResult"
Hopefully this is what you are looking for.
Regards,
Tom
Hey,
I guess this DAX statement used with a calculated column creates what you are looking for:
result = var currentCustomer = 'Table1'[Customer] var currentItem = 'Table1'[Item] var minDate = CALCULATE( MIN('Table1'[Purchase Date]) ,ALL(Table1) ,'Table1'[Customer] = currentCustomer ,'Table1'[Item] = currentItem ) return IF( AND( AND('Table1'[Customer] = currentCustomer, 'Table1'[Item] = currentItem) ,'Table1'[Purchase Date] = minDate ) ,"First Purchase" ,"Re Purchase" )
At least the new column "result" contains the same values of the column COLUMN from the sample data you provided, please note that I renamed the column from the test data to "TestResult"
Hopefully this is what you are looking for.
Regards,
Tom
Hi, Tom.
This is great. Everything works as how it supposed to do.
Thanks so much!!!
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 |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |