The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I need some help.
I have a table with information about sale and repurchase. When I make a purchase and then regret my purchase, it ends up on its own line with the tag "repurchase". The order ID is the same. I would like a table that count sales who have the same orderID and purchases and repurchase at the same time.
My data
Date | Time | OrderID | Type of purchase |
2022-12-08 | 10:52:00 | DFPN-7856 | sale |
2022-12-08 | 10:53:00 | DFPN-7856 | repurchase |
2022-12-31 | 12:19:00 | EGTP-7156 | sale |
2022-12-31 | 12:19:00 | EGTP-7156 | repurchase |
2022-12-30 | 04:37:00 | ERTV-7516 | sale |
2022-12-30 | 04:37:00 | ERTV-7516 | repurchase |
2023-01-24 | 14:55:00 | FVGT-6572 | sale |
2023-01-24 | 14:55:00 | FVGT-6572 | repurchase |
2023-01-09 | 16:10:00 | GHTP-1257 | sale |
2023-01-09 | 16:10:00 | GHTP-1257 | repurchase |
2022-12-01 | 07:45:00 | GTPJ-9751 | sale |
2022-12-01 | 07:52:00 | GTPJ-9751 | repurchase |
2023-01-10 | 16:50:00 | JYYA-5888 | sale |
2023-01-10 | 16:50:00 | JYYA-5888 | repurchase |
2022-12-04 | 19:33:00 | LPWB-7853 | sale |
2022-12-04 | 19:33:00 | LPWB-7853 | repurchase |
2022-12-06 | 21:34:00 | QLPG-3256 | sale |
2022-12-06 | 21:54:00 | QLPG-3256 | repurchase |
2022-12-12 | 14:35:00 | RTEV-6587 | sale |
2022-12-12 | 15:48:00 | RTEV-6587 | repurchase |
2022-12-01 | 21:35:00 | WEFD-3657 | sale |
2022-12-01 | 21:35:00 | WEFD-3657 | repurchase |
2023-01-07 | 18:42:00 | WERT-3657 | sale |
2023-01-07 | 19:08:00 | WERT-3657 | repurchase |
The resualt I want:
Date | Resualt | |
2022-12-01 | 1 | |
2022-12-04 | 1 | |
2022-12-30 | 1 | |
2022-12-31 | 1 | |
2023-01-09 | 1 | |
2023-01-10 | 1 | |
2023-01-24 | 1 | |
Solved! Go to Solution.
You can use
Sale & repurchase =
VAR Sales = CALCULATETABLE(
SUMMARIZE( 'Table', 'Table'[OrderID], 'Table'[Time]),
'Table'[Type of purchase] = "sale"
)
VAR Repurchases = CALCULATETABLE(
SUMMARIZE( 'Table', 'Table'[OrderID], 'Table'[Time]),
'Table'[Type of purchase] = "repurchase"
)
VAR Result = COUNTROWS( INTERSECT( Sales, Repurchases))
RETURN Result
Thank you very much. I worked.
You can use
Sale & repurchase =
VAR Sales = CALCULATETABLE(
SUMMARIZE( 'Table', 'Table'[OrderID], 'Table'[Time]),
'Table'[Type of purchase] = "sale"
)
VAR Repurchases = CALCULATETABLE(
SUMMARIZE( 'Table', 'Table'[OrderID], 'Table'[Time]),
'Table'[Type of purchase] = "repurchase"
)
VAR Result = COUNTROWS( INTERSECT( Sales, Repurchases))
RETURN Result
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |