I'm trying to find the intersect of two result sets using DAX, but I'm really struggling to get the two result sets calculated.I have a fact table, FactCheckForUpdates, that has a relationship to a date table called 'Log Date'. FactCheckForUpdates contains Machine IDs, and I want to return the IDs for the last 2 complete months.I can calculate the distinct count of Machine IDs using this formula: [code="other"]2Month Distinct Machines:=CALCULATE ( [Distinct Machine Ids], FILTER( ALL( 'Log Date' ), ( 'Log Date'[YearMonthNumber] >= MAX( 'Log Date'[YearMonthNumber] ) - 3 ) && ( 'Log Date'[YearMonthNumber] <= MAX( 'Log Date'[YearMonthNumber] ) - 1 ) ) )[/code]Where 'Distinct Machine Ids' is calculated as: [code="other"]:=DISTINCTCOUNT([MachineId])[/code]and where 'YearMonthNumber' is calculated on the 'Log Date' table as: [code="other"]=('Log Date'[YearKey] - MIN('Log Date'[YearKey])) * 12 + 'Log Date'[MonthOfYearKey][/code](effectively this gives the number of the month in the context of the entire date dimension).[b]Can anyone help me update the [2Month Distinct Machines] expression so that instead of returning the distinct count of Machine IDs in the period, it returns a table of the machine IDs?[/b]I've tried using the CALCULATETABLE function, but it won't accept the MAX aggregate on the date filter. The closest I've gotten is this formula: [code="other"]CALCULATETABLE ( ADDCOLUMNS ( SUMMARIZE ( FactCheckForUpdates, FactCheckForUpdates[MachineId] ), "meh", CALCULATE ( SUM ( FactCheckForUpdates[CFUPing] ) ) ), FactCheckForUpdates[LogDateKey] > DATE ( 2016, 4, 1 ) )[/code]but I'm not sure how to use the 'Log Date' table here.Any help massively appreciated!
↧