Forum Discussion
Create relation in 2 tables
- 8 years ago
You can create a measure with following DAX formula without creating relationship between these two tables.
Measure = VAR TempDate = CALCULATE ( MAX ( Table1[Date] ) ) VAR TempExpectedSales = CALCULATE ( SUM ( Table2[Expected Sales] ), FILTER ( ALL ( Table2 ), Table2[Date] = TempDate ) ) RETURN CALCULATE ( SUM ( Table1[Actual Sales] ) ) / TempExpectedSalesBest Regards,
Herbert
You can create a measure with following DAX formula without creating relationship between these two tables.
Measure =
VAR TempDate =
CALCULATE ( MAX ( Table1[Date] ) )
VAR TempExpectedSales =
CALCULATE (
SUM ( Table2[Expected Sales] ),
FILTER ( ALL ( Table2 ), Table2[Date] = TempDate )
)
RETURN
CALCULATE ( SUM ( Table1[Actual Sales] ) ) / TempExpectedSales
Best Regards,
Herbert
It works on my file, thanks a lot.
I have a last question, here is my formula :
RETURN
(CALCULATE(CALCULATE(SUM('Table1'[Actual Sales]);OR('Table1[Filter]=1;'Table1'[Filter1]=2));'Table1'[Filter2]="00164"))/TempExpectedSales
But I want Filter2 (in red) not to be fixed. Can I use a code to change this filter from the rapport? It would be perfect if I could use a segment to change the filter of the measure directly to make the changes dynamic.
I don't know if I'm clear, again thanks a lot for your solution.