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
ddpl
Solution Sage
Solution Sage

I want to create a new table contains last purchase of individual customer from order table.

I had a table contained multiple customers order details with date and time. From that table I want to create a new table that contain last purchase/order of each customer with all the product details(remaining columns from source table

 

Thanks in Advance.

 

RequirementRequirementSourceSource

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@ddpl this is an alternative solution:

 

New Calculated Table = 
	VAR _filter = 
		TREATAS(
			ADDCOLUMNS(
				VALUES('Table'[Customer ID]),
				"@Last Date", CALCULATE(MAX('Table'[Date]))
			),
			'Table'[Customer ID], 'Table'[Date]
		)
	RETURN
		CALCULATETABLE(
			'Table',
			_filter
		)

 

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

2 REPLIES 2
SpartaBI
Community Champion
Community Champion

@ddpl this is an alternative solution:

 

New Calculated Table = 
	VAR _filter = 
		TREATAS(
			ADDCOLUMNS(
				VALUES('Table'[Customer ID]),
				"@Last Date", CALCULATE(MAX('Table'[Date]))
			),
			'Table'[Customer ID], 'Table'[Date]
		)
	RETURN
		CALCULATETABLE(
			'Table',
			_filter
		)

 

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

SpartaBI
Community Champion
Community Champion

@ddpl 

 

New Calculated Table = 
	SELECTCOLUMNS(
		GENERATE(
			SELECTCOLUMNS(
				ADDCOLUMNS(
					VALUES('Table'[Customer ID]), 
					"@Last Date", CALCULATE(MAX('Table'[Date]))
				),
				"@Customer ID", [Customer ID] & "",
				"@Last Date", [@Last Date]
			),
			VAR _current_customer = [@Customer ID]
			RETURN
			FILTER(
				'Table',
				'Table'[Date] = [@Last Date]
					&& 'Table'[Customer ID] = _current_customer
			)
		),
		"Customer ID", [Customer ID],
		"Date", [Date],
		"Product ID", [Product ID],
		"Product Color", [Product Color],
		"Price", [Price]
)
		
	

 




2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

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.