Issue with DAX query to sum a field in a table if another table has certain keys

24 Views Asked by At

Good Morning,

I'm creating a measure for a report and have run into a few issues. I've only been using DAX for about a month and aren't familiar with the nuances.

I have 3 tables that I'm working with. tblSales tblFactID tblDIMID

The measure I'm trying to create is where if tblFactID[Key] NOT IN tblDIMID[Key] then SUM(tblSales[Sales]).

tblSales shares a key with tblFactID and tblFactID shares a key with tblDIMID, if any of that matters for this.

This is what I have in DAX Studio where I get "The expression specified in the query is not a valid table expression"

DEFINE var a = CALCULATETABLE(VALUES('tblDIMID'[Key], FILTER('tblDIMID', NOT('tblDIMID[Key] IN VALUES('tblFactID[Key]))))

EVALUATE CALCULATE ( SUM('tblSales'[Sales]), FILTER('tblFactID, 'tblFactID'[Key] IN a) )

I'm sure there is a better way to do this but my knowledge on the subject is limited.

I've been searching around for a few days and this is what I've come up with so far. I'm not familiar enough with the topic to know what I'm looking for to get this accomplished.

0

There are 0 best solutions below