Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Josefin1234
New Member

Count sales during the same time

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

DateTimeOrderIDType of purchase
2022-12-0810:52:00DFPN-7856sale
2022-12-0810:53:00DFPN-7856repurchase
2022-12-3112:19:00EGTP-7156sale
2022-12-3112:19:00EGTP-7156repurchase
2022-12-3004:37:00ERTV-7516sale
2022-12-3004:37:00ERTV-7516repurchase
2023-01-2414:55:00FVGT-6572sale
2023-01-2414:55:00FVGT-6572repurchase
2023-01-0916:10:00GHTP-1257sale
2023-01-0916:10:00GHTP-1257repurchase
2022-12-0107:45:00GTPJ-9751sale
2022-12-0107:52:00GTPJ-9751repurchase
2023-01-1016:50:00JYYA-5888sale
2023-01-1016:50:00JYYA-5888repurchase
2022-12-0419:33:00LPWB-7853sale
2022-12-0419:33:00LPWB-7853repurchase
2022-12-0621:34:00QLPG-3256sale
2022-12-0621:54:00QLPG-3256repurchase
2022-12-1214:35:00RTEV-6587sale
2022-12-1215:48:00RTEV-6587repurchase
2022-12-0121:35:00WEFD-3657sale
2022-12-0121:35:00WEFD-3657repurchase
2023-01-0718:42:00WERT-3657sale
2023-01-0719:08:00WERT-3657repurchase


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
   
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

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

View solution in original post

2 REPLIES 2
Josefin1234
New Member

Thank you very much. I worked. 

johnt75
Super User
Super User

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors