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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ErikWarming
New Member

Filter orders have have one partikular product

I have a Semantic Model / Powerbi Dataset / Dimentional model with a fct.Saleslines and a dim.product.

ErikWarming_2-1700823550240.png

 

In the fctSalesline have have an OrderID (SK_Orders) and several ProductID's (SK_Product) pr order

I want to identify all the orders, with all their products, who has a partikular kind of product.

 

I can do it SQL. Here is two orders (6665943  and 6665944) and all their products. One of the product in order 6665943 is a StarProduct and I want to see all the product of that order. 

ErikWarming_0-1700823024194.png

The SK_Order column to the right marks the all the SK_Products in the order 6665943  , where one of the products are a start product. While order 6665944 has not star products.

 

But how do I do that with DAX? It have to be something similar to my SQL statement, first make a filter that identifies the SK_Orders and then use the selected SK_Orders to filter the fct tabel again.

 

ErikWarming_4-1700823769032.png

 

 

 

 

 

1 REPLY 1
Fowmy
Super User
Super User

@ErikWarming 

Try the following query to get the desired result:

EVALUATE
VAR __Orders = 
	 FILTER(
		fctSalesline , 
		fctSalesline[SK_Order] IN { 6665943,6665944} 
	)
RETURN 
	ADDCOLUMNS(
		__Orders,
			"StarProducts",  RELATED(dim_product[ LableGroupName_StarProducts])
		,
		"StarProductOrder", 
			VAR __Order = fctSalesline[SK_Order]
			VAR __CurrOrders =  FILTER(	ALL(fctSalesline) , fctSalesline[SK_Order] =  __Order )
			RETURN
			MAXX(
				FILTER(
			 		__CurrOrders,
			  		RELATED(dim_product[ LableGroupName_StarProducts]) = 1), 
				fctSalesline[SK_Order] 
			)			
	)

 

Fowmy_0-1700829166376.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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