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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

DAX filter data - SQL - NOT EXISTS

Hi,

 

Who can help me?

 

For a BI solution i have a dataset with many tabels (Orders, Orderdetail, etc etc)

In one visual I have to show all the records that is the result of the next query

 

SELECT DISTINCT o.oKey, o.OrderNumber, o.OrderType, o.AckDate, o.Date, ISNULL(os.TargetShipDate, '') AS TargetShipDate, o.ReqDate
		FROM FVMASTER.dbo.Orders o
			INNER JOIN FVMASTER.dbo.OrderDetail od ON o.okey=od.okey
			INNER JOIN FVMASTER.dbo.OrderDetailParts odp ON od.odKey=odp.odKey
			INNER JOIN FVMASTER.dbo.OrderDetailPurchaseReqs odpr ON odpr.odKey=odp.odKey AND odpr.MasterKey = odp.MasterKey AND odpr.ParentKey = odp.ParentKey
			LEFT JOIN (
					--Retrieve the earliest target ship date for any shipments (includes transfer shipments)
					SELECT oKey, MIN(TargetShipDate) AS TargetShipDate
					FROM FVMASTER.dbo.OrderShipments
					GROUP BY oKey
					) os ON o.oKey = os.oKey
			WHERE NOT EXISTS(
					SELECT * 
					FROM FVMASTER.dbo.OrderDetail od2 
					WHERE o.oKey=od2.oKey 
					AND od2.PurchasingReqsEvaluated=0 
					AND od2.ItemType<>5 AND od2.SubLineItem >= 0
					) 
					AND o.AckDate<>'' 
					AND o.OrderType IN (1,4,5) 
					AND o.ClosedDate='' 
					AND o.Cancelled=0 
					AND od.PurchasingReqsEvaluated=1 
					AND odpr.OrderDate=''
		
		GROUP BY o.oKey, o.OrderNumber, o.OrderType, o.AckDate, o.Date, os.TargetShipDate, o.ReqDate
		

I realy don't know how to realise this. 

At this moment I have a seperate SQL view that i load in PowerBi. But this is not the way to go, because this subdataset is not a part of mij datamodel. 

 

 

1 REPLY 1
Eric_Zhang
Microsoft Employee
Microsoft Employee

@Anonymous

May I know where do you get stuck? You could try to import the tables individually into Power BI desktop tables and create proper relationship among them.

 

For further suggestion, is it possible to upload a pbix file containing your tables and expected output? You could upload the pbix file to a web storage like Onedrive and share a the link in a private message. Do mask sensitve data before uploading.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.